@readme/httpsnippet 4.0.4 → 4.0.5
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 +0 -11
- package/dist/index.js +4 -0
- package/package.json +1 -1
|
@@ -69,17 +69,6 @@ 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
|
-
}
|
|
83
72
|
throw new HARError(validate.errors);
|
|
84
73
|
}
|
|
85
74
|
return true;
|
package/dist/index.js
CHANGED
|
@@ -275,6 +275,10 @@ var HTTPSnippet = /** @class */ (function () {
|
|
|
275
275
|
var req = __assign({ bodySize: 0, headersSize: 0, headers: [], cookies: [], httpVersion: 'HTTP/1.1', queryString: [], postData: {
|
|
276
276
|
mimeType: ((_b = request.postData) === null || _b === void 0 ? void 0 : _b.mimeType) || 'application/octet-stream'
|
|
277
277
|
} }, request);
|
|
278
|
+
// Per the HAR spec `mimeType` needs to always be present if we have a `postData` object.
|
|
279
|
+
if (req.postData && !req.postData.mimeType) {
|
|
280
|
+
req.postData.mimeType = 'application/octet-stream';
|
|
281
|
+
}
|
|
278
282
|
if ((0, har_validator_1.validateHarRequest)(req)) {
|
|
279
283
|
_this.requests.push(_this.prepare(req, options));
|
|
280
284
|
}
|
package/package.json
CHANGED