Skip to content

Commit 60470e2

Browse files
author
SGrondin
committed
OCaml body fix
1 parent 2ef7b65 commit 60470e2

7 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/targets/ocaml/cohttp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = function (source, options) {
3434
// Add body
3535
if (source.postData.text) {
3636
// Just text
37-
code.push(util.format('let body = %s in', JSON.stringify(source.postData.text)))
37+
code.push(util.format('let body = Cohttp_lwt_body.of_string %s in', JSON.stringify(source.postData.text)))
3838
}
3939

4040
// Do the request

test/fixtures/output/ocaml/cohttp/application-form-encoded.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let uri = Uri.of_string "http://mockbin.com/har" in
66
let headers = Header.init ()
77
|> fun h -> Header.add h "content-type" "application/x-www-form-urlencoded"
88
in
9-
let body = "foo=bar&hello=world" in
9+
let body = Cohttp_lwt_body.of_string "foo=bar&hello=world" in
1010

1111
Client.call ~headers ~body `POST uri
1212
>>= fun (res, body_stream) ->

test/fixtures/output/ocaml/cohttp/application-json.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let uri = Uri.of_string "http://mockbin.com/har" in
66
let headers = Header.init ()
77
|> fun h -> Header.add h "content-type" "application/json"
88
in
9-
let body = "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }" in
9+
let body = Cohttp_lwt_body.of_string "{\"number\": 1, \"string\": \"f\\\"oo\", \"arr\": [1, 2, 3], \"nested\": {\"a\": \"b\"}, \"arr_mix\": [1, \"a\", {\"arr_mix_nested\": {}}] }" in
1010

1111
Client.call ~headers ~body `POST uri
1212
>>= fun (res, body_stream) ->

test/fixtures/output/ocaml/cohttp/full.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let headers = Header.init ()
88
|> fun h -> Header.add h "accept" "application/json"
99
|> fun h -> Header.add h "content-type" "application/x-www-form-urlencoded"
1010
in
11-
let body = "foo=bar" in
11+
let body = Cohttp_lwt_body.of_string "foo=bar" in
1212

1313
Client.call ~headers ~body `POST uri
1414
>>= fun (res, body_stream) ->

test/fixtures/output/ocaml/cohttp/multipart-data.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let uri = Uri.of_string "http://mockbin.com/har" in
66
let headers = Header.init ()
77
|> fun h -> Header.add h "content-type" "multipart/form-data; boundary=---011000010111000001101001"
88
in
9-
let body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\nHello World\r\n-----011000010111000001101001--" in
9+
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\nHello World\r\n-----011000010111000001101001--" in
1010

1111
Client.call ~headers ~body `POST uri
1212
>>= fun (res, body_stream) ->

test/fixtures/output/ocaml/cohttp/multipart-file.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let uri = Uri.of_string "http://mockbin.com/har" in
66
let headers = Header.init ()
77
|> fun h -> Header.add h "content-type" "multipart/form-data; boundary=---011000010111000001101001"
88
in
9-
let body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001--" in
9+
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001--" in
1010

1111
Client.call ~headers ~body `POST uri
1212
>>= fun (res, body_stream) ->

test/fixtures/output/ocaml/cohttp/multipart-form-data.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let uri = Uri.of_string "http://mockbin.com/har" in
66
let headers = Header.init ()
77
|> fun h -> Header.add h "content-type" "multipart/form-data; boundary=---011000010111000001101001"
88
in
9-
let body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--" in
9+
let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--" in
1010

1111
Client.call ~headers ~body `POST uri
1212
>>= fun (res, body_stream) ->

0 commit comments

Comments
 (0)