Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[fix] web_client: broken behaviour with custom headers fixed

  • Loading branch information...
commit 21375f37cb437324f7fdea42b2d1e030c6d0e2c4 1 parent 37aa517
Nicolas Glondu authored
Showing with 8 additions and 6 deletions.
  1. +4 −2 libnet/http_client.ml
  2. +4 −4 stdlib/core/web/client/web_client.opa
View
6 libnet/http_client.ml
@@ -83,7 +83,7 @@ let place_request (sched: Scheduler.t) ~hostname ~port ~path
else Network.Unsecured
in
let port_spec = Network.make_port_spec ~protocol:http machine port in
- let command = Printf.sprintf "%s %s %s%s%sHost: %s%sUser-Agent: %s%s%s%s"
+ let command = Printf.sprintf "%s %s %s%s%sHost: %s%sUser-Agent: %s%s%s%s%s"
request_kind
path
http_version
@@ -92,7 +92,9 @@ let place_request (sched: Scheduler.t) ~hostname ~port ~path
(if port = 80 then hostname else Printf.sprintf "%s:%d" hostname port)
Base.crlf
client_name
- (Printf.sprintf "%s%s" Base.crlf more_headers)
+ Base.crlf
+ (if more_headers = "" then ""
+ else Printf.sprintf "%s%s" more_headers Base.crlf)
Base.crlf
data
in
View
8 stdlib/core/web/client/web_client.opa
@@ -561,10 +561,10 @@ WebClient =
length = match options.content with
| {none} -> 0
| ~{some} -> String.length(some)
- post_headers = "Content-Length: {length}\r\nContent-Type: {options.mimetype}\r\n"
+ post_headers = "Content-Length: {length}\r\nContent-Type: {options.mimetype}"
headers = match options.custom_headers with
| {none} -> post_headers
- | ~{some} -> "{post_headers}{some}"
+ | ~{some} -> "{post_headers}\r\n{some}"
generic_options = {
operation = "POST"
auth = options.auth
@@ -719,10 +719,10 @@ WebClient =
try_put_with_options_async(location, content, default_options, on_result)
try_put_with_options_async(location:Uri.uri, content:string, options:WebClient.Put.options, on_result: WebClient.result(string) -> void): void =
length = String.length(content)
- put_headers = "Content-Length: {length}\r\nContent-Type: {options.mimetype}\r\n"
+ put_headers = "Content-Length: {length}\r\nContent-Type: {options.mimetype}"
headers = match options.custom_headers with
| {none} -> put_headers
- | ~{some} -> "{put_headers}{some}"
+ | ~{some} -> "{put_headers}\r\n{some}"
generic_options = {
operation = "PUT"
auth = options.auth
Please sign in to comment.
Something went wrong with that request. Please try again.