accept http1.0

This commit is contained in:
Simon Cruanes 2020-05-27 13:23:02 -04:00
parent 5c56cb7f1e
commit eaa2c9b3b7

View file

@ -456,10 +456,13 @@ module Request = struct
try try
let line = Byte_stream.read_line ~buf bs in let line = Byte_stream.read_line ~buf bs in
let meth, path = let meth, path =
try Scanf.sscanf line "%s %s HTTP/1.1\r" (fun x y->x,y) try
with _ -> let m, p, v = Scanf.sscanf line "%s %s HTTP/1.%d\r" (fun x y z->x,y,z) in
_debug (fun k->k "invalid request line: `%s`" line); if v != 0 && v != 1 then raise Exit;
raise (Bad_req (400, "Invalid request line")) m, p
with _ ->
_debug (fun k->k "invalid request line: `%s`" line);
raise (Bad_req (400, "Invalid request line"))
in in
let meth = Meth.of_string meth in let meth = Meth.of_string meth in
_debug (fun k->k "got meth: %s, path %S" (Meth.to_string meth) path); _debug (fun k->k "got meth: %s, path %S" (Meth.to_string meth) path);