Support ?-terminated hostnames per RFC 2396.3.2.

- Bust out of s_req_host and s_req_port on '?'.
- Add tests for query string parsing.

Fixes #38.
v0.6
Peter Griess 14 years ago committed by Ryan Dahl
parent 50b9bec552
commit 9639c7c21c

@ -740,6 +740,9 @@ size_t http_parser_execute (http_parser *parser,
CALLBACK(url);
state = s_req_http_start;
break;
case '?':
state = s_req_query_string_start;
break;
default:
goto error;
}
@ -762,6 +765,9 @@ size_t http_parser_execute (http_parser *parser,
CALLBACK(url);
state = s_req_http_start;
break;
case '?':
state = s_req_query_string_start;
break;
default:
goto error;
}

@ -603,6 +603,63 @@ const struct message requests[] =
,.body= ""
}
#define QUERY_TERMINATED_HOST 22
, {.name= "host terminated by a query string"
,.type= HTTP_REQUEST
,.raw= "GET http://hypnotoad.org?hail=all HTTP/1.1\r\n"
"\r\n"
,.should_keep_alive= TRUE
,.message_complete_on_eof= FALSE
,.http_major= 1
,.http_minor= 1
,.method= HTTP_GET
,.query_string= "hail=all"
,.fragment= ""
,.request_path= ""
,.request_url= "http://hypnotoad.org?hail=all"
,.num_headers= 0
,.headers= { }
,.body= ""
}
#define QUERY_TERMINATED_HOSTPORT 23
, {.name= "host:port terminated by a query string"
,.type= HTTP_REQUEST
,.raw= "GET http://hypnotoad.org:1234?hail=all HTTP/1.1\r\n"
"\r\n"
,.should_keep_alive= TRUE
,.message_complete_on_eof= FALSE
,.http_major= 1
,.http_minor= 1
,.method= HTTP_GET
,.query_string= "hail=all"
,.fragment= ""
,.request_path= ""
,.request_url= "http://hypnotoad.org:1234?hail=all"
,.num_headers= 0
,.headers= { }
,.body= ""
}
#define SPACE_TERMINATED_HOSTPORT 24
, {.name= "host:port terminated by a space"
,.type= HTTP_REQUEST
,.raw= "GET http://hypnotoad.org:1234 HTTP/1.1\r\n"
"\r\n"
,.should_keep_alive= TRUE
,.message_complete_on_eof= FALSE
,.http_major= 1
,.http_minor= 1
,.method= HTTP_GET
,.query_string= ""
,.fragment= ""
,.request_path= ""
,.request_url= "http://hypnotoad.org:1234"
,.num_headers= 0
,.headers= { }
,.body= ""
}
, {.name= NULL } /* sentinel */
};

Loading…
Cancel
Save