]> granicus.if.org Git - esp-idf/commitdiff
Modified http_parser to handle ICY uris.
authorVikram Dattu <vikram.dattu@espressif.com>
Thu, 26 Sep 2019 05:54:13 +0000 (11:24 +0530)
committerbot <bot@espressif.com>
Fri, 11 Oct 2019 05:04:08 +0000 (05:04 +0000)
ICY URIs e.g `http://uk1.internet-radio.com/proxy/vombat?mp=/;` need to
be handled differently.

For basic use case, these URIs are similar to HTTP with exception that they reply with `ICY 200` etc in place of `HTTP/1.1 200`.

In http_parser, we now also parse ICY URIs to be able to handle these similar to HTTP.

Signed-off-by: Vikram Dattu <vikram.dattu@espressif.com>
components/nghttp/port/http_parser.c

index 8c1f4dd077752fce59996953aba8079790210381..ef1ecd48c6aec122a1dbe132096fcda9713b964c 100644 (file)
@@ -280,8 +280,11 @@ enum state
   { s_dead = 1 /* important that this is > 0 */
 
   , s_start_req_or_res
+  , s_res_or_resp_I /* for ICY URIs */
   , s_res_or_resp_H
   , s_start_res
+  , s_res_I         /* for ICY URIs */
+  , s_res_IC        /* for ICY URIs */
   , s_res_H
   , s_res_HT
   , s_res_HTT
@@ -728,6 +731,10 @@ reexecute:
         if (ch == 'H') {
           UPDATE_STATE(s_res_or_resp_H);
 
+          CALLBACK_NOTIFY(message_begin);
+        } else if (ch == 'I') {
+          UPDATE_STATE(s_res_or_resp_I);
+
           CALLBACK_NOTIFY(message_begin);
         } else {
           parser->type = HTTP_REQUEST;
@@ -738,6 +745,13 @@ reexecute:
         break;
       }
 
+      case s_res_or_resp_I: /* ICY URI case */
+        if (ch == 'C') {
+          parser->type = HTTP_RESPONSE;
+          UPDATE_STATE(s_res_IC);
+        }
+        break;
+
       case s_res_or_resp_H:
         if (ch == 'T') {
           parser->type = HTTP_RESPONSE;
@@ -764,7 +778,9 @@ reexecute:
           case 'H':
             UPDATE_STATE(s_res_H);
             break;
-
+          case 'I': /* ICY URI */
+            UPDATE_STATE(s_res_I);
+            break;
           case CR:
           case LF:
             break;
@@ -777,6 +793,15 @@ reexecute:
         CALLBACK_NOTIFY(message_begin);
         break;
       }
+      case s_res_I:
+        STRICT_CHECK(ch != 'C');
+        UPDATE_STATE(s_res_IC);
+        break;
+
+      case s_res_IC:
+        STRICT_CHECK(ch != 'Y');
+        UPDATE_STATE(s_res_http_minor);
+        break;
 
       case s_res_H:
         STRICT_CHECK(ch != 'T');