, s_header_field_start
, s_header_field
+ , s_header_value_discard_ws
+ , s_header_value_discard_ws_almost_done
+ , s_header_value_discard_lws
, s_header_value_start
, s_header_value
, s_header_value_lws
}
if (ch == ':') {
- parser->state = s_header_value_start;
+ parser->state = s_header_value_discard_ws;
CALLBACK_DATA(header_field);
break;
}
goto error;
}
- case s_header_value_start:
- {
+ case s_header_value_discard_ws:
if (ch == ' ' || ch == '\t') break;
- MARK(header_value);
-
- parser->state = s_header_value;
- parser->index = 0;
-
if (ch == CR) {
- parser->header_state = h_general;
- parser->state = s_header_almost_done;
- CALLBACK_DATA(header_value);
+ parser->state = s_header_value_discard_ws_almost_done;
break;
}
if (ch == LF) {
- parser->state = s_header_field_start;
- CALLBACK_DATA(header_value);
+ parser->state = s_header_value_discard_lws;
break;
}
+ /* FALLTHROUGH */
+
+ case s_header_value_start:
+ {
+ MARK(header_value);
+
+ parser->state = s_header_value;
+ parser->index = 0;
+
c = LOWER(ch);
switch (parser->header_state) {
STRICT_CHECK(ch != LF);
parser->state = s_header_value_lws;
+ break;
+ }
+
+ case s_header_value_lws:
+ {
+ if (ch == ' ' || ch == '\t') {
+ parser->state = s_header_value_start;
+ goto reexecute_byte;
+ }
+ /* finished the header */
switch (parser->header_state) {
case h_connection_keep_alive:
parser->flags |= F_CONNECTION_KEEP_ALIVE;
break;
}
+ parser->state = s_header_field_start;
+ goto reexecute_byte;
+ }
+
+ case s_header_value_discard_ws_almost_done:
+ {
+ STRICT_CHECK(ch != LF);
+ parser->state = s_header_value_discard_lws;
break;
}
- case s_header_value_lws:
+ case s_header_value_discard_lws:
{
- if (ch == ' ' || ch == '\t')
- parser->state = s_header_value_start;
- else
- {
+ if (ch == ' ' || ch == '\t') {
+ parser->state = s_header_value_discard_ws;
+ break;
+ } else {
+ /* header value was empty */
+ MARK(header_value);
parser->state = s_header_field_start;
+ CALLBACK_DATA_NOADVANCE(header_value);
goto reexecute_byte;
}
- break;
}
case s_headers_almost_done:
" mno \r\n"
"\t \tqrs\r\n"
"Line2: \t line2\t\r\n"
+ "Line3:\r\n"
+ " line3\r\n"
+ "Line4: \r\n"
+ " \r\n"
+ "Connection:\r\n"
+ " close\r\n"
"\r\n"
- ,.should_keep_alive= TRUE
+ ,.should_keep_alive= FALSE
,.message_complete_on_eof= FALSE
,.http_major= 1
,.http_minor= 1
,.fragment= ""
,.request_path= "/"
,.request_url= "/"
- ,.num_headers= 2
- ,.headers= { { "Line1", "abcdefghijklmno qrs" }
+ ,.num_headers= 5
+ ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" }
, { "Line2", "line2\t" }
+ , { "Line3", "line3" }
+ , { "Line4", "" }
+ , { "Connection", "close" },
}
,.body= ""
}
,.body= ""
}
+#define LINE_FOLDING_IN_HEADER_WITH_LF 34
+, {.name= "line folding in header value"
+ ,.type= HTTP_REQUEST
+ ,.raw= "GET / HTTP/1.1\n"
+ "Line1: abc\n"
+ "\tdef\n"
+ " ghi\n"
+ "\t\tjkl\n"
+ " mno \n"
+ "\t \tqrs\n"
+ "Line2: \t line2\t\n"
+ "Line3:\n"
+ " line3\n"
+ "Line4: \n"
+ " \n"
+ "Connection:\n"
+ " close\n"
+ "\n"
+ ,.should_keep_alive= FALSE
+ ,.message_complete_on_eof= FALSE
+ ,.http_major= 1
+ ,.http_minor= 1
+ ,.method= HTTP_GET
+ ,.query_string= ""
+ ,.fragment= ""
+ ,.request_path= "/"
+ ,.request_url= "/"
+ ,.num_headers= 5
+ ,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" }
+ , { "Line2", "line2\t" }
+ , { "Line3", "line3" }
+ , { "Line4", "" }
+ , { "Connection", "close" },
+ }
+ ,.body= ""
+ }
+
, {.name= NULL } /* sentinel */
};