diff --git a/http_parser.rl b/http_parser.rl index 18d0360..b08d09a 100644 --- a/http_parser.rl +++ b/http_parser.rl @@ -378,8 +378,8 @@ do { \ Request_Line = ( Method " " Request_URI ("#" Fragment)? " " HTTP_Version CRLF ) ; StatusCode = (digit digit digit) $status_code; - ReasonPhrase = ascii+ -- ("\r" | "\n"); - StatusLine = HTTP_Version " " StatusCode " " ReasonPhrase CRLF; + ReasonPhrase = ascii* -- ("\r" | "\n"); + StatusLine = HTTP_Version " " StatusCode (" " ReasonPhrase)? CRLF; # chunked message trailing_headers = header*; diff --git a/test.c b/test.c index 6188629..ba8329f 100644 --- a/test.c +++ b/test.c @@ -354,6 +354,16 @@ const struct message responses[] = ,.body= "" } +, {.name= "301 no response phrase" + ,.type= HTTP_RESPONSE + ,.raw= "HTTP/1.1 301\r\n\r\n" + ,.should_keep_alive = TRUE + ,.status_code= 301 + ,.num_headers= 0 + ,.headers= {} + ,.body= "" +} + , {.name= NULL } /* sentinel */ };