Skip to content

Commit 4db7036

Browse files
gschierdarrenjennings
authored andcommitted
Add multiline test fixture
1 parent 43f6369 commit 4db7036

File tree

26 files changed

+359
-2
lines changed

26 files changed

+359
-2
lines changed

src/targets/shell/curl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module.exports = function (source, options) {
7575
if (source.postData.text) {
7676
code.push(
7777
'%s %s', opts.binary ? '--data-binary' : (opts.short ? '-d' : '--data'),
78-
helpers.escape(helpers.quote(source.postData.text))
78+
helpers.quote(source.postData.text)
7979
)
8080
}
8181
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CURL *hnd = curl_easy_init();
2+
3+
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
4+
curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har");
5+
6+
struct curl_slist *headers = NULL;
7+
headers = curl_slist_append(headers, "content-type: application/json");
8+
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
9+
10+
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"foo\": \"bar\"\n}");
11+
12+
CURLcode ret = curl_easy_perform(hnd);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var client = new RestClient("http://mockbin.com/har");
2+
var request = new RestRequest(Method.POST);
3+
request.AddHeader("content-type", "application/json");
4+
request.AddParameter("application/json", "{\n \"foo\": \"bar\"\n}", ParameterType.RequestBody);
5+
IRestResponse response = client.Execute(request);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
"net/http"
7+
"io/ioutil"
8+
)
9+
10+
func main() {
11+
12+
url := "http://mockbin.com/har"
13+
14+
payload := strings.NewReader("{\n \"foo\": \"bar\"\n}")
15+
16+
req, _ := http.NewRequest("POST", url, payload)
17+
18+
req.Header.Add("content-type", "application/json")
19+
20+
res, _ := http.DefaultClient.Do(req)
21+
22+
defer res.Body.Close()
23+
body, _ := ioutil.ReadAll(res.Body)
24+
25+
fmt.Println(res)
26+
fmt.Println(string(body))
27+
28+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
OkHttpClient client = new OkHttpClient();
2+
3+
MediaType mediaType = MediaType.parse("application/json");
4+
RequestBody body = RequestBody.create(mediaType, "{\n \"foo\": \"bar\"\n}");
5+
Request request = new Request.Builder()
6+
.url("http://mockbin.com/har")
7+
.post(body)
8+
.addHeader("content-type", "application/json")
9+
.build();
10+
11+
Response response = client.newCall(request).execute();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
HttpResponse<String> response = Unirest.post("http://mockbin.com/har")
2+
.header("content-type", "application/json")
3+
.body("{\n \"foo\": \"bar\"\n}")
4+
.asString();
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var settings = {
2+
"async": true,
3+
"crossDomain": true,
4+
"url": "http://mockbin.com/har",
5+
"method": "POST",
6+
"headers": {
7+
"content-type": "application/json"
8+
},
9+
"processData": false,
10+
"data": "{\n \"foo\": \"bar\"\n}"
11+
}
12+
13+
$.ajax(settings).done(function (response) {
14+
console.log(response);
15+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var data = JSON.stringify({
2+
"foo": "bar"
3+
});
4+
5+
var xhr = new XMLHttpRequest();
6+
xhr.withCredentials = true;
7+
8+
xhr.addEventListener("readystatechange", function () {
9+
if (this.readyState === this.DONE) {
10+
console.log(this.responseText);
11+
}
12+
});
13+
14+
xhr.open("POST", "http://mockbin.com/har");
15+
xhr.setRequestHeader("content-type", "application/json");
16+
17+
xhr.send(data);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var http = require("http");
2+
3+
var options = {
4+
"method": "POST",
5+
"hostname": "mockbin.com",
6+
"port": null,
7+
"path": "/har",
8+
"headers": {
9+
"content-type": "application/json"
10+
}
11+
};
12+
13+
var req = http.request(options, function (res) {
14+
var chunks = [];
15+
16+
res.on("data", function (chunk) {
17+
chunks.push(chunk);
18+
});
19+
20+
res.on("end", function () {
21+
var body = Buffer.concat(chunks);
22+
console.log(body.toString());
23+
});
24+
});
25+
26+
req.write(JSON.stringify({foo: 'bar'}));
27+
req.end();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
var request = require("request");
2+
3+
var options = {
4+
method: 'POST',
5+
url: 'http://mockbin.com/har',
6+
headers: {'content-type': 'application/json'},
7+
body: {foo: 'bar'},
8+
json: true
9+
};
10+
11+
request(options, function (error, response, body) {
12+
if (error) throw new Error(error);
13+
14+
console.log(body);
15+
});
16+

0 commit comments

Comments
 (0)