@readme/httpsnippet 4.0.3 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/har-validator.js +11 -0
- package/dist/targets/javascript/axios/fixtures/postdata-malformed.d.ts +1 -0
- package/dist/targets/javascript/axios/fixtures/postdata-malformed.js +18 -0
- package/dist/targets/javascript/fetch/fixtures/postdata-malformed.d.ts +6 -0
- package/dist/targets/javascript/fetch/fixtures/postdata-malformed.js +5 -0
- package/dist/targets/javascript/jquery/fixtures/postdata-malformed.d.ts +9 -0
- package/dist/targets/javascript/jquery/fixtures/postdata-malformed.js +13 -0
- package/dist/targets/javascript/xhr/fixtures/postdata-malformed.d.ts +2 -0
- package/dist/targets/javascript/xhr/fixtures/postdata-malformed.js +12 -0
- package/dist/targets/node/axios/fixtures/postdata-malformed.d.ts +1 -0
- package/dist/targets/node/axios/fixtures/postdata-malformed.js +14 -0
- package/dist/targets/node/fetch/fixtures/postdata-malformed.d.ts +1 -0
- package/dist/targets/node/fetch/fixtures/postdata-malformed.js +7 -0
- package/dist/targets/node/native/fixtures/postdata-malformed.d.ts +1 -0
- package/dist/targets/node/native/fixtures/postdata-malformed.js +22 -0
- package/dist/targets/node/request/fixtures/postdata-malformed.d.ts +1 -0
- package/dist/targets/node/request/fixtures/postdata-malformed.js +12 -0
- package/dist/targets/node/unirest/fixtures/postdata-malformed.d.ts +1 -0
- package/dist/targets/node/unirest/fixtures/postdata-malformed.js +11 -0
- package/package.json +1 -1
|
@@ -69,6 +69,17 @@ var validateHarRequest = function (request) {
|
|
|
69
69
|
}
|
|
70
70
|
var valid = validate(request);
|
|
71
71
|
if (!valid && validate.errors) {
|
|
72
|
+
if (validate.errors.length === 1) {
|
|
73
|
+
// While not ideal, or compliant with the HAR spec, if we have an empty `postData` object in
|
|
74
|
+
// our HAR and no other errors we should let this through because it's fine and our client
|
|
75
|
+
// targets are able to handle it okay.
|
|
76
|
+
var error = validate.errors[0];
|
|
77
|
+
if (error.dataPath === '.postData' &&
|
|
78
|
+
error.message === "should have required property 'mimeType'" &&
|
|
79
|
+
JSON.stringify(request.postData) === '{}') {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
72
83
|
throw new HARError(validate.errors);
|
|
73
84
|
}
|
|
74
85
|
return true;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
exports.__esModule = true;
|
|
6
|
+
var axios_1 = __importDefault(require("axios"));
|
|
7
|
+
var options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
url: 'https://httpbin.org/anything',
|
|
10
|
+
headers: { 'content-type': 'application/json' }
|
|
11
|
+
};
|
|
12
|
+
axios_1["default"]
|
|
13
|
+
.request(options)
|
|
14
|
+
.then(function (response) {
|
|
15
|
+
console.log(response.data);
|
|
16
|
+
})["catch"](function (error) {
|
|
17
|
+
console.error(error);
|
|
18
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var options = { method: 'POST', headers: { 'content-type': 'application/json' } };
|
|
3
|
+
fetch('https://httpbin.org/anything', options)
|
|
4
|
+
.then(function (response) { return response.json(); })
|
|
5
|
+
.then(function (response) { return console.log(response); })["catch"](function (err) { return console.error(err); });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var settings = {
|
|
3
|
+
async: true,
|
|
4
|
+
crossDomain: true,
|
|
5
|
+
url: 'https://httpbin.org/anything',
|
|
6
|
+
method: 'POST',
|
|
7
|
+
headers: {
|
|
8
|
+
'content-type': 'application/json'
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
$.ajax(settings).done(function (response) {
|
|
12
|
+
console.log(response);
|
|
13
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var data = null;
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.withCredentials = true;
|
|
5
|
+
xhr.addEventListener('readystatechange', function () {
|
|
6
|
+
if (this.readyState === this.DONE) {
|
|
7
|
+
console.log(this.responseText);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
xhr.open('POST', 'https://httpbin.org/anything');
|
|
11
|
+
xhr.setRequestHeader('content-type', 'application/json');
|
|
12
|
+
xhr.send(data);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var axios = require('axios')["default"];
|
|
3
|
+
var options = {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
url: 'https://httpbin.org/anything',
|
|
6
|
+
headers: { 'content-type': 'application/json' }
|
|
7
|
+
};
|
|
8
|
+
axios
|
|
9
|
+
.request(options)
|
|
10
|
+
.then(function (response) {
|
|
11
|
+
console.log(response.data);
|
|
12
|
+
})["catch"](function (error) {
|
|
13
|
+
console.error(error);
|
|
14
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var fetch = require('node-fetch');
|
|
3
|
+
var url = 'https://httpbin.org/anything';
|
|
4
|
+
var options = { method: 'POST', headers: { 'content-type': 'application/json' } };
|
|
5
|
+
fetch(url, options)
|
|
6
|
+
.then(function (res) { return res.json(); })
|
|
7
|
+
.then(function (json) { return console.log(json); })["catch"](function (err) { return console.error('error:' + err); });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var http = require('https');
|
|
3
|
+
var options = {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
hostname: 'httpbin.org',
|
|
6
|
+
port: null,
|
|
7
|
+
path: '/anything',
|
|
8
|
+
headers: {
|
|
9
|
+
'content-type': 'application/json'
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var req = http.request(options, function (res) {
|
|
13
|
+
var chunks = [];
|
|
14
|
+
res.on('data', function (chunk) {
|
|
15
|
+
chunks.push(chunk);
|
|
16
|
+
});
|
|
17
|
+
res.on('end', function () {
|
|
18
|
+
var body = Buffer.concat(chunks);
|
|
19
|
+
console.log(body.toString());
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
req.end();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var request = require('request');
|
|
3
|
+
var options = {
|
|
4
|
+
method: 'POST',
|
|
5
|
+
url: 'https://httpbin.org/anything',
|
|
6
|
+
headers: { 'content-type': 'application/json' }
|
|
7
|
+
};
|
|
8
|
+
request(options, function (error, response, body) {
|
|
9
|
+
if (error)
|
|
10
|
+
throw new Error(error);
|
|
11
|
+
console.log(body);
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var unirest = require('unirest');
|
|
3
|
+
var req = unirest('POST', 'https://httpbin.org/anything');
|
|
4
|
+
req.headers({
|
|
5
|
+
'content-type': 'application/json'
|
|
6
|
+
});
|
|
7
|
+
req.end(function (res) {
|
|
8
|
+
if (res.error)
|
|
9
|
+
throw new Error(res.error);
|
|
10
|
+
console.log(res.body);
|
|
11
|
+
});
|
package/package.json
CHANGED