mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 11:15:35 -05:00
perf: simpler parsing of headers
This commit is contained in:
parent
0138f22826
commit
ddd337cc61
1 changed files with 5 additions and 1 deletions
|
|
@ -329,7 +329,11 @@ module Headers = struct
|
||||||
acc
|
acc
|
||||||
) else (
|
) else (
|
||||||
let k,v =
|
let k,v =
|
||||||
try Scanf.sscanf line "%s@: %s@\r" (fun k v->k,v)
|
try
|
||||||
|
let i = String.index line ':' in
|
||||||
|
let k = String.sub line 0 i in
|
||||||
|
let v = String.sub line (i+1) (String.length line-i-1) |> String.trim in
|
||||||
|
k,v
|
||||||
with _ -> bad_reqf 400 "invalid header line: %S" line
|
with _ -> bad_reqf 400 "invalid header line: %S" line
|
||||||
in
|
in
|
||||||
loop ((String.lowercase_ascii k,v)::acc)
|
loop ((String.lowercase_ascii k,v)::acc)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue