@readme/httpsnippet 8.1.4 → 10.0.0
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/LICENSE +1 -1
- package/README.md +7 -7
- package/dist/{chunk-ENNB4GTT.js → chunk-R65NNSSK.js} +5 -5
- package/dist/chunk-R65NNSSK.js.map +1 -0
- package/dist/helpers/code-builder.d.cts +1 -1
- package/dist/helpers/code-builder.d.ts +1 -1
- package/dist/helpers/reducer.d.cts +1 -1
- package/dist/helpers/reducer.d.ts +1 -1
- package/dist/{index-09744b29.d.ts → index-BTuTGf5t.d.ts} +5 -5
- package/dist/{index-d5b13104.d.ts → index-C-fCLOHv.d.cts} +5 -5
- package/dist/index.cjs +32 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30 -19
- package/dist/index.js.map +1 -1
- package/dist/targets/index.cjs +4 -4
- package/dist/targets/index.cjs.map +1 -1
- package/dist/targets/index.d.cts +1 -1
- package/dist/targets/index.d.ts +1 -1
- package/dist/targets/index.js +1 -1
- package/package.json +10 -11
- package/dist/chunk-ENNB4GTT.js.map +0 -1
|
@@ -117,8 +117,8 @@ declare class HTTPSnippet {
|
|
|
117
117
|
requests: Request[];
|
|
118
118
|
options: HTTPSnippetOptions;
|
|
119
119
|
constructor(input: HarEntry | HarRequest, opts?: HTTPSnippetOptions);
|
|
120
|
-
init():
|
|
121
|
-
prepare(harRequest: HarRequest, options: HTTPSnippetOptions):
|
|
120
|
+
init(): this;
|
|
121
|
+
prepare(harRequest: HarRequest, options: HTTPSnippetOptions): {
|
|
122
122
|
allHeaders: {
|
|
123
123
|
[x: string]: string | string[];
|
|
124
124
|
};
|
|
@@ -157,8 +157,8 @@ declare class HTTPSnippet {
|
|
|
157
157
|
cookiesObj: ReducedHelperObject;
|
|
158
158
|
headersObj: ReducedHelperObject;
|
|
159
159
|
queryObj: ReducedHelperObject;
|
|
160
|
-
}
|
|
161
|
-
convert(targetId: TargetId, clientId?: ClientId, options?: any):
|
|
160
|
+
};
|
|
161
|
+
convert(targetId: TargetId, clientId?: ClientId, options?: any): false | string[];
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
export { ClientId as C, Extension as E, HarRequest as H, RequestExtras as R, TargetId as T, ClientInfo as a, Converter as b, Client as c, ClientPlugin as d, TargetInfo as e, Target as f, addTarget as g, isClient as h, isTarget as i, addClientPlugin as j, addTargetClient as k, Request as l, HTTPSnippetOptions as m, HTTPSnippet as n, availableTargets as o, extname as p, targets as t };
|
|
164
|
+
export { type ClientId as C, type Extension as E, type HarRequest as H, type RequestExtras as R, type TargetId as T, type ClientInfo as a, type Converter as b, type Client as c, type ClientPlugin as d, type TargetInfo as e, type Target as f, addTarget as g, isClient as h, isTarget as i, addClientPlugin as j, addTargetClient as k, type Request as l, type HTTPSnippetOptions as m, HTTPSnippet as n, availableTargets as o, extname as p, targets as t };
|
|
@@ -117,8 +117,8 @@ declare class HTTPSnippet {
|
|
|
117
117
|
requests: Request[];
|
|
118
118
|
options: HTTPSnippetOptions;
|
|
119
119
|
constructor(input: HarEntry | HarRequest, opts?: HTTPSnippetOptions);
|
|
120
|
-
init():
|
|
121
|
-
prepare(harRequest: HarRequest, options: HTTPSnippetOptions):
|
|
120
|
+
init(): this;
|
|
121
|
+
prepare(harRequest: HarRequest, options: HTTPSnippetOptions): {
|
|
122
122
|
allHeaders: {
|
|
123
123
|
[x: string]: string | string[];
|
|
124
124
|
};
|
|
@@ -157,8 +157,8 @@ declare class HTTPSnippet {
|
|
|
157
157
|
cookiesObj: ReducedHelperObject;
|
|
158
158
|
headersObj: ReducedHelperObject;
|
|
159
159
|
queryObj: ReducedHelperObject;
|
|
160
|
-
}
|
|
161
|
-
convert(targetId: TargetId, clientId?: ClientId, options?: any):
|
|
160
|
+
};
|
|
161
|
+
convert(targetId: TargetId, clientId?: ClientId, options?: any): false | string[];
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
export { ClientId as C, Extension as E, HarRequest as H, RequestExtras as R, TargetId as T, ClientInfo as a, Converter as b, Client as c, ClientPlugin as d, TargetInfo as e, Target as f, addTarget as g, isClient as h, isTarget as i, addClientPlugin as j, addTargetClient as k, Request as l, HTTPSnippetOptions as m, HTTPSnippet as n, availableTargets as o, extname as p, targets as t };
|
|
164
|
+
export { type ClientId as C, type Extension as E, type HarRequest as H, type RequestExtras as R, type TargetId as T, type ClientInfo as a, type Converter as b, type Client as c, type ClientPlugin as d, type TargetInfo as e, type Target as f, addTarget as g, isClient as h, isTarget as i, addClientPlugin as j, addTargetClient as k, type Request as l, type HTTPSnippetOptions as m, HTTPSnippet as n, availableTargets as o, extname as p, targets as t };
|
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var url = require('url');
|
|
4
|
-
var formDataToString = require('formdata-to-string');
|
|
5
4
|
var qs = require('qs');
|
|
6
5
|
var stringifyObject9 = require('stringify-object');
|
|
7
6
|
|
|
8
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
8
|
|
|
10
|
-
var formDataToString__default = /*#__PURE__*/_interopDefault(formDataToString);
|
|
11
9
|
var stringifyObject9__default = /*#__PURE__*/_interopDefault(stringifyObject9);
|
|
12
10
|
|
|
13
11
|
// src/index.ts
|
|
@@ -3034,11 +3032,11 @@ ${indent}` : " "
|
|
|
3034
3032
|
postData.params?.forEach((param) => {
|
|
3035
3033
|
let post = "";
|
|
3036
3034
|
if (param.fileName) {
|
|
3037
|
-
post = `${param.name}
|
|
3035
|
+
post = `${param.name}='@${param.fileName}'`;
|
|
3038
3036
|
} else {
|
|
3039
|
-
post = `${param.name}=${param.value}
|
|
3037
|
+
post = quote(`${param.name}=${param.value}`);
|
|
3040
3038
|
}
|
|
3041
|
-
push(`${arg("form")} ${
|
|
3039
|
+
push(`${arg("form")} ${post}`);
|
|
3042
3040
|
});
|
|
3043
3041
|
break;
|
|
3044
3042
|
case "application/x-www-form-urlencoded":
|
|
@@ -3048,7 +3046,7 @@ ${indent}` : " "
|
|
|
3048
3046
|
const encoded = encodeURIComponent(param.name);
|
|
3049
3047
|
const needsEncoding = encoded !== unencoded;
|
|
3050
3048
|
const name = needsEncoding ? encoded : unencoded;
|
|
3051
|
-
const flag = binary ? "--data-binary" :
|
|
3049
|
+
const flag = binary ? "--data-binary" : needsEncoding ? "--data-urlencode" : arg("data");
|
|
3052
3050
|
push(`${flag} ${quote(`${name}=${param.value}`)}`);
|
|
3053
3051
|
});
|
|
3054
3052
|
} else {
|
|
@@ -3574,10 +3572,9 @@ var HTTPSnippet = class {
|
|
|
3574
3572
|
];
|
|
3575
3573
|
}
|
|
3576
3574
|
}
|
|
3577
|
-
|
|
3575
|
+
init() {
|
|
3578
3576
|
this.initCalled = true;
|
|
3579
|
-
|
|
3580
|
-
this.entries.forEach(({ request: request2 }) => {
|
|
3577
|
+
this.requests = this.entries.map(({ request: request2 }) => {
|
|
3581
3578
|
const req = {
|
|
3582
3579
|
bodySize: 0,
|
|
3583
3580
|
headersSize: 0,
|
|
@@ -3593,12 +3590,11 @@ var HTTPSnippet = class {
|
|
|
3593
3590
|
if (req.postData && !req.postData.mimeType) {
|
|
3594
3591
|
req.postData.mimeType = "application/octet-stream";
|
|
3595
3592
|
}
|
|
3596
|
-
|
|
3593
|
+
return this.prepare(req, this.options);
|
|
3597
3594
|
});
|
|
3598
|
-
this.requests = await Promise.all(promises);
|
|
3599
3595
|
return this;
|
|
3600
3596
|
}
|
|
3601
|
-
|
|
3597
|
+
prepare(harRequest, options) {
|
|
3602
3598
|
const request2 = {
|
|
3603
3599
|
...harRequest,
|
|
3604
3600
|
fullUrl: "",
|
|
@@ -3647,21 +3643,34 @@ var HTTPSnippet = class {
|
|
|
3647
3643
|
request2.postData.text = "";
|
|
3648
3644
|
request2.postData.mimeType = "multipart/form-data";
|
|
3649
3645
|
if (request2.postData?.params) {
|
|
3650
|
-
const
|
|
3651
|
-
|
|
3646
|
+
const boundary = "---011000010111000001101001";
|
|
3647
|
+
const carriage = `${boundary}--`;
|
|
3648
|
+
const rn = "\r\n";
|
|
3649
|
+
const escape2 = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
|
|
3650
|
+
const normalizeLinefeeds = (value) => value.replace(/\r?\n|\r/g, "\r\n");
|
|
3651
|
+
const payload = [`--${boundary}`];
|
|
3652
|
+
request2.postData?.params.forEach((param, i) => {
|
|
3652
3653
|
const name = param.name;
|
|
3653
3654
|
const value = param.value || "";
|
|
3654
3655
|
const filename = param.fileName || null;
|
|
3655
|
-
const contentType = param.contentType || "";
|
|
3656
|
+
const contentType = param.contentType || "application/octet-stream";
|
|
3656
3657
|
if (filename) {
|
|
3657
|
-
|
|
3658
|
+
payload.push(
|
|
3659
|
+
`Content-Disposition: form-data; name="${escape2(normalizeLinefeeds(name))}"; filename="${filename}"`
|
|
3660
|
+
);
|
|
3661
|
+
payload.push(`Content-Type: ${contentType}`);
|
|
3658
3662
|
} else {
|
|
3659
|
-
|
|
3663
|
+
payload.push(`Content-Disposition: form-data; name="${escape2(normalizeLinefeeds(name))}"`);
|
|
3664
|
+
}
|
|
3665
|
+
payload.push("");
|
|
3666
|
+
payload.push(normalizeLinefeeds(value));
|
|
3667
|
+
if (i !== request2.postData.params.length - 1) {
|
|
3668
|
+
payload.push(`--${boundary}`);
|
|
3660
3669
|
}
|
|
3661
3670
|
});
|
|
3662
|
-
|
|
3671
|
+
payload.push(`--${carriage}`);
|
|
3663
3672
|
request2.postData.boundary = boundary;
|
|
3664
|
-
request2.postData.text =
|
|
3673
|
+
request2.postData.text = payload.join(rn);
|
|
3665
3674
|
const contentTypeHeader = getHeaderName(request2.headersObj, "content-type") || "content-type";
|
|
3666
3675
|
request2.headersObj[contentTypeHeader] = `multipart/form-data; boundary=${boundary}`;
|
|
3667
3676
|
}
|
|
@@ -3731,9 +3740,9 @@ var HTTPSnippet = class {
|
|
|
3731
3740
|
uriObj
|
|
3732
3741
|
};
|
|
3733
3742
|
}
|
|
3734
|
-
|
|
3743
|
+
convert(targetId, clientId, options) {
|
|
3735
3744
|
if (!this.initCalled) {
|
|
3736
|
-
|
|
3745
|
+
this.init();
|
|
3737
3746
|
}
|
|
3738
3747
|
if (!options && clientId) {
|
|
3739
3748
|
options = clientId;
|
|
@@ -3744,9 +3753,10 @@ var HTTPSnippet = class {
|
|
|
3744
3753
|
}
|
|
3745
3754
|
const { convert } = target.clientsById[clientId || target.info.default];
|
|
3746
3755
|
const results = this.requests.map((request2) => convert(request2, options));
|
|
3747
|
-
return results
|
|
3756
|
+
return results;
|
|
3748
3757
|
}
|
|
3749
3758
|
};
|
|
3759
|
+
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
|
3750
3760
|
|
|
3751
3761
|
exports.HTTPSnippet = HTTPSnippet;
|
|
3752
3762
|
exports.addClientPlugin = addClientPlugin;
|