Skip to content

Commit

Permalink
[fix] libnet,stdlib: Fixes for http_client parsing problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
nrs135 authored and cedricss committed Mar 8, 2012
1 parent b55f000 commit ee4c464
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions libnet/http/request.trx
Expand Up @@ -37,14 +37,14 @@ open RequestType

+response : {Requestdef.Value.value Requestdef.RequestHeader.t} <-
/ ResponseLine headers {{ __2 }}
RequestLine <- Word Space+ ((!EOL !Space . )+ $_) Space+ Word EOL
RequestLine <- Word Space+ ((!EOL !Space . )+ $_) Space+ AnyWord EOL
{{ { _method = method_of_string __1 ; request_uri = __3 ; http_version = __5 } }}

# We need to accept HTTP/0.9 requests.
RequestLineShort <- Word Space+ Word EOL
{{ { _method = method_of_string __1 ; request_uri = __3 ; http_version = "HTTP/0.9" } }}

ResponseLine <- Word Space+ ([0-9]+ $_) (Space+ Word)+ EOL
ResponseLine <- Word Space+ ([0-9]+ $_) (Space+ AnyWord)+ EOL
{{ __1, int_of_string(__3) }}

response_headers <- Header response_headers {{ let k, v = __1 in try ResponseHeader.add (response_header_of_string k) v __2 with (Parsing _) -> __2 }}
Expand All @@ -65,6 +65,8 @@ Value <- ((![;,\r\n] . {{ __2 }})+ $_) ([;] Space* ((![,\r\n] . {{__2 }})+ $_) {

Word <- Char+ $_
Char <- !(FullSpace $ / [:] $) . {{ __2 }}
AnyWord <- AnyChar+ $_
AnyChar <- !(FullSpace $) . {{ __2 }}

Space <- ' ' / '\t'
FullSpace <- Space / EOL
Expand Down
2 changes: 1 addition & 1 deletion stdlib/core/web/core/uri.opa
Expand Up @@ -268,7 +268,7 @@ UriParser =
query_parser = Rule.parse_list(query_element, parser [&;] -> void)

query =
parser "?" query=query_parser -> query
parser "?" "&"? query=query_parser -> query

fragment = parser
| "#" fragment=chars -> fragment
Expand Down

0 comments on commit ee4c464

Please sign in to comment.