@scalar/snippetz 0.7.7 → 0.8.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/dist/httpsnippet-lite/targets/c/libcurl/client.d.ts.map +1 -1
- package/dist/httpsnippet-lite/targets/c/libcurl/client.js +4 -2
- package/dist/libs/http.d.ts +2 -2
- package/dist/libs/http.d.ts.map +1 -1
- package/dist/libs/http.js +14 -18
- package/dist/plugins/csharp/httpclient/httpclient.d.ts.map +1 -1
- package/dist/plugins/csharp/httpclient/httpclient.js +2 -3
- package/dist/plugins/dart/http/http.d.ts.map +1 -1
- package/dist/plugins/dart/http/http.js +1 -4
- package/dist/plugins/http/http11/http11.d.ts.map +1 -1
- package/dist/plugins/http/http11/http11.js +2 -6
- package/dist/plugins/js/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/js/fetch/fetch.js +2 -3
- package/dist/plugins/node/fetch/fetch.d.ts.map +1 -1
- package/dist/plugins/node/fetch/fetch.js +2 -3
- package/dist/plugins/node/undici/undici.d.ts.map +1 -1
- package/dist/plugins/node/undici/undici.js +2 -3
- package/dist/plugins/php/curl/curl.d.ts.map +1 -1
- package/dist/plugins/php/curl/curl.js +20 -16
- package/dist/plugins/python/requestsLike.d.ts.map +1 -1
- package/dist/plugins/python/requestsLike.js +7 -3
- package/dist/plugins/shell/curl/curl.d.ts.map +1 -1
- package/dist/plugins/shell/curl/curl.js +1 -3
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/targets/c/libcurl/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../src/httpsnippet-lite/targets/c/libcurl/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAA;AAE/D,eAAO,MAAM,OAAO,EAAE,MAqErB,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CodeBuilder } from '../../../../httpsnippet-lite/helpers/code-builder.js';
|
|
2
2
|
import { escapeForDoubleQuotes } from '../../../../httpsnippet-lite/helpers/escape.js';
|
|
3
|
-
import { createSearchParams } from '../../../../libs/http.js';
|
|
4
3
|
export const libcurl = {
|
|
5
4
|
info: {
|
|
6
5
|
key: 'libcurl',
|
|
@@ -42,7 +41,10 @@ export const libcurl = {
|
|
|
42
41
|
push(`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, ${JSON.stringify(postData.text)});`);
|
|
43
42
|
}
|
|
44
43
|
else if (postData.mimeType === 'application/x-www-form-urlencoded' && postData.params) {
|
|
45
|
-
|
|
44
|
+
const formBody = postData.params
|
|
45
|
+
.map((param) => new URLSearchParams([[param.name, param.value ?? '']]).toString())
|
|
46
|
+
.join('&');
|
|
47
|
+
push(`curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "${formBody}");`);
|
|
46
48
|
}
|
|
47
49
|
else if (postData.mimeType === 'multipart/form-data' && postData.params) {
|
|
48
50
|
push('curl_mime *mime = curl_mime_init(hnd);');
|
package/dist/libs/http.d.ts
CHANGED
|
@@ -13,9 +13,9 @@ export declare function buildQueryString(queryParams?: Array<{
|
|
|
13
13
|
value: string;
|
|
14
14
|
}>): string;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Adds a named value while preserving repeated keys as arrays.
|
|
17
17
|
*/
|
|
18
|
-
export declare const
|
|
18
|
+
export declare const accumulateRepeatedValue: (data: Record<string, string | string[]>, name: string, value: string) => void;
|
|
19
19
|
/**
|
|
20
20
|
* Reduces query parameters into an object while preserving repeated keys as arrays.
|
|
21
21
|
*/
|
package/dist/libs/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/libs/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAKvG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,CAO7F;AAED;;GAEG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/libs/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAExD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAKvG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,MAAM,CAO7F;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,IAU9G,CAAA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,GAAE,UAAU,CAAC,aAAa,CAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAQ1G;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBnF"}
|
package/dist/libs/http.js
CHANGED
|
@@ -14,34 +14,30 @@ export function buildQueryString(queryParams) {
|
|
|
14
14
|
if (!queryParams?.length) {
|
|
15
15
|
return '';
|
|
16
16
|
}
|
|
17
|
-
const queryPairs = queryParams.map((param) => `${
|
|
17
|
+
const queryPairs = queryParams.map((param) => `${param.name}=${param.value}`);
|
|
18
18
|
return `?${queryPairs.join('&')}`;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Adds a named value while preserving repeated keys as arrays.
|
|
22
22
|
*/
|
|
23
|
-
export const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
23
|
+
export const accumulateRepeatedValue = (data, name, value) => {
|
|
24
|
+
const existingValue = data[name];
|
|
25
|
+
if (existingValue === undefined) {
|
|
26
|
+
data[name] = value;
|
|
27
|
+
}
|
|
28
|
+
else if (Array.isArray(existingValue)) {
|
|
29
|
+
existingValue.push(value);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
data[name] = [existingValue, value];
|
|
33
|
+
}
|
|
29
34
|
};
|
|
30
35
|
/**
|
|
31
36
|
* Reduces query parameters into an object while preserving repeated keys as arrays.
|
|
32
37
|
*/
|
|
33
38
|
export function reduceQueryParams(query = []) {
|
|
34
39
|
return query.reduce((acc, { name, value }) => {
|
|
35
|
-
|
|
36
|
-
if (existingValue === undefined) {
|
|
37
|
-
acc[name] = value;
|
|
38
|
-
}
|
|
39
|
-
else if (Array.isArray(existingValue)) {
|
|
40
|
-
existingValue.push(value);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
acc[name] = [existingValue, value];
|
|
44
|
-
}
|
|
40
|
+
accumulateRepeatedValue(acc, name, value);
|
|
45
41
|
return acc;
|
|
46
42
|
}, {});
|
|
47
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpclient.d.ts","sourceRoot":"","sources":["../../../../src/plugins/csharp/httpclient/httpclient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAuB,MAAM,wBAAwB,CAAA;AAKzE;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"httpclient.d.ts","sourceRoot":"","sources":["../../../../src/plugins/csharp/httpclient/httpclient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAuB,MAAM,wBAAwB,CAAA;AAKzE;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MA2C9B,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { encode } from 'js-base64';
|
|
2
|
-
import {
|
|
2
|
+
import { buildQueryString } from '../../../libs/http.js';
|
|
3
3
|
/**
|
|
4
4
|
* csharp/httpclient
|
|
5
5
|
*/
|
|
@@ -17,8 +17,7 @@ export const csharpHttpclient = {
|
|
|
17
17
|
// Normalization
|
|
18
18
|
normalizedRequest.method = normalizedRequest.method.toUpperCase();
|
|
19
19
|
// Build URL with query string
|
|
20
|
-
const
|
|
21
|
-
const queryString = searchParams.size ? `?${searchParams.toString()}` : '';
|
|
20
|
+
const queryString = buildQueryString(normalizedRequest.queryString);
|
|
22
21
|
const url = `${normalizedRequest.url}${queryString}`;
|
|
23
22
|
// Start building the snippet
|
|
24
23
|
const lines = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dart/http/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dart/http/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,MAyGtB,CAAA"}
|
|
@@ -56,10 +56,7 @@ export const dartHttp = {
|
|
|
56
56
|
}
|
|
57
57
|
// Handle query string
|
|
58
58
|
const queryString = normalizedRequest.queryString?.length
|
|
59
|
-
? '?' +
|
|
60
|
-
normalizedRequest.queryString
|
|
61
|
-
.map((param) => `${encodeURIComponent(param.name)}=${encodeURIComponent(param.value)}`)
|
|
62
|
-
.join('&')
|
|
59
|
+
? '?' + normalizedRequest.queryString.map((param) => `${param.name}=${param.value}`).join('&')
|
|
63
60
|
: '';
|
|
64
61
|
const url = `${normalizedRequest.url}${queryString}`;
|
|
65
62
|
// Handle body
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http11.d.ts","sourceRoot":"","sources":["../../../../src/plugins/http/http11/http11.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"http11.d.ts","sourceRoot":"","sources":["../../../../src/plugins/http/http11/http11.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAkHxB,CAAA"}
|
|
@@ -31,9 +31,7 @@ export const httpHttp11 = {
|
|
|
31
31
|
let requestString = `${normalizedRequest.method} ${path} HTTP/1.1\r\n`;
|
|
32
32
|
// Handle query string parameters
|
|
33
33
|
if (normalizedRequest.queryString.length) {
|
|
34
|
-
const queryString = normalizedRequest.queryString
|
|
35
|
-
.map((param) => `${encodeURIComponent(param.name)}=${encodeURIComponent(param.value)}`)
|
|
36
|
-
.join('&');
|
|
34
|
+
const queryString = normalizedRequest.queryString.map((param) => `${param.name}=${param.value}`).join('&');
|
|
37
35
|
// Append query string to the path
|
|
38
36
|
requestString = `${normalizedRequest.method} ${path}?${queryString} HTTP/1.1\r\n`;
|
|
39
37
|
}
|
|
@@ -52,9 +50,7 @@ export const httpHttp11 = {
|
|
|
52
50
|
});
|
|
53
51
|
// Query string parameters
|
|
54
52
|
if (normalizedRequest.queryString.length) {
|
|
55
|
-
const queryString = normalizedRequest.queryString
|
|
56
|
-
.map((param) => `${encodeURIComponent(param.name)}=${encodeURIComponent(param.value)}`)
|
|
57
|
-
.join('&');
|
|
53
|
+
const queryString = normalizedRequest.queryString.map((param) => `${param.name}=${param.value}`).join('&');
|
|
58
54
|
// Append query string to the path
|
|
59
55
|
requestString = `${normalizedRequest.method} ${path}?${queryString} HTTP/1.1\r\n`;
|
|
60
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/js/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MAsFrB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildQueryString } from '../../../libs/http.js';
|
|
2
2
|
import { Raw, objectToString } from '../../../libs/javascript.js';
|
|
3
3
|
/**
|
|
4
4
|
* js/fetch
|
|
@@ -21,8 +21,7 @@ export const jsFetch = {
|
|
|
21
21
|
method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,
|
|
22
22
|
};
|
|
23
23
|
// Query
|
|
24
|
-
const
|
|
25
|
-
const queryString = searchParams.size ? `?${searchParams.toString()}` : '';
|
|
24
|
+
const queryString = buildQueryString(normalizedRequest.queryString);
|
|
26
25
|
// Headers
|
|
27
26
|
if (normalizedRequest.headers?.length) {
|
|
28
27
|
options.headers = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/fetch/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MA2FvB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildQueryString } from '../../../libs/http.js';
|
|
2
2
|
import { Raw, objectToString } from '../../../libs/javascript.js';
|
|
3
3
|
/**
|
|
4
4
|
* node/fetch
|
|
@@ -21,8 +21,7 @@ export const nodeFetch = {
|
|
|
21
21
|
method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,
|
|
22
22
|
};
|
|
23
23
|
// Query
|
|
24
|
-
const
|
|
25
|
-
const queryString = searchParams.size ? `?${searchParams.toString()}` : '';
|
|
24
|
+
const queryString = buildQueryString(normalizedRequest.queryString);
|
|
26
25
|
// Headers
|
|
27
26
|
if (normalizedRequest.headers?.length) {
|
|
28
27
|
options.headers = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"undici.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/undici/undici.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"undici.d.ts","sourceRoot":"","sources":["../../../../src/plugins/node/undici/undici.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAKpD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAoExB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildQueryString } from '../../../libs/http.js';
|
|
2
2
|
import { Raw, objectToString } from '../../../libs/javascript.js';
|
|
3
3
|
/**
|
|
4
4
|
* node/undici
|
|
@@ -20,8 +20,7 @@ export const nodeUndici = {
|
|
|
20
20
|
method: normalizedRequest.method === 'GET' ? undefined : normalizedRequest.method,
|
|
21
21
|
};
|
|
22
22
|
// Query
|
|
23
|
-
const
|
|
24
|
-
const queryString = searchParams.size ? `?${searchParams.toString()}` : '';
|
|
23
|
+
const queryString = buildQueryString(normalizedRequest.queryString);
|
|
25
24
|
// Headers
|
|
26
25
|
if (normalizedRequest.headers?.length) {
|
|
27
26
|
options.headers = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../../../src/plugins/php/curl/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../../../src/plugins/php/curl/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE,MA+JrB,CAAA"}
|
|
@@ -16,15 +16,14 @@ export const phpCurl = {
|
|
|
16
16
|
normalizedRequest.method = normalizedRequest.method.toUpperCase();
|
|
17
17
|
// Build PHP cURL code parts
|
|
18
18
|
const parts = [];
|
|
19
|
+
let hasMultipartMimeBody = false;
|
|
19
20
|
// Initialize cURL
|
|
20
21
|
// URL (with query parameters)
|
|
21
22
|
const queryString = normalizedRequest.queryString?.length
|
|
22
23
|
? '?' +
|
|
23
24
|
normalizedRequest.queryString
|
|
24
25
|
.map((param) => {
|
|
25
|
-
|
|
26
|
-
const encodedValue = encodeURIComponent(param.value);
|
|
27
|
-
return `${encodedName}=${encodedValue}`;
|
|
26
|
+
return `${param.name}=${param.value}`;
|
|
28
27
|
})
|
|
29
28
|
.join('&')
|
|
30
29
|
: '';
|
|
@@ -46,12 +45,7 @@ export const phpCurl = {
|
|
|
46
45
|
const hasContentType = () => allHeaders.some((h) => h.name.toLowerCase() === 'content-type');
|
|
47
46
|
// Determine Content-Type from body before emitting headers
|
|
48
47
|
if (normalizedRequest.postData) {
|
|
49
|
-
if (normalizedRequest.postData.mimeType === '
|
|
50
|
-
normalizedRequest.postData.params &&
|
|
51
|
-
!hasContentType()) {
|
|
52
|
-
allHeaders.push({ name: 'Content-Type', value: 'multipart/form-data' });
|
|
53
|
-
}
|
|
54
|
-
else if (normalizedRequest.postData.mimeType === 'application/x-www-form-urlencoded' &&
|
|
48
|
+
if (normalizedRequest.postData.mimeType === 'application/x-www-form-urlencoded' &&
|
|
55
49
|
normalizedRequest.postData.params &&
|
|
56
50
|
!hasContentType()) {
|
|
57
51
|
allHeaders.push({ name: 'Content-Type', value: 'application/x-www-form-urlencoded' });
|
|
@@ -97,17 +91,24 @@ export const phpCurl = {
|
|
|
97
91
|
}
|
|
98
92
|
}
|
|
99
93
|
else if (normalizedRequest.postData.mimeType === 'multipart/form-data' && normalizedRequest.postData.params) {
|
|
100
|
-
//
|
|
101
|
-
|
|
94
|
+
// Build multipart payload with curl_mime_* so duplicate keys remain distinct parts.
|
|
95
|
+
hasMultipartMimeBody = true;
|
|
96
|
+
parts.push('$mime = curl_mime_init($ch);');
|
|
97
|
+
normalizedRequest.postData.params.forEach((param, index) => {
|
|
98
|
+
const partName = `$part${index}`;
|
|
99
|
+
parts.push(`${partName} = curl_mime_addpart($mime);`);
|
|
100
|
+
parts.push(`curl_mime_name(${partName}, '${param.name}');`);
|
|
102
101
|
if (param.fileName !== undefined) {
|
|
103
|
-
|
|
102
|
+
parts.push(`curl_mime_filedata(${partName}, '${param.fileName}');`);
|
|
104
103
|
}
|
|
105
104
|
else if (param.value !== undefined) {
|
|
106
|
-
|
|
105
|
+
parts.push(`curl_mime_data(${partName}, '${param.value}');`);
|
|
107
106
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
107
|
+
if (param.contentType) {
|
|
108
|
+
parts.push(`curl_mime_type(${partName}, '${param.contentType}');`);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
parts.push('curl_setopt($ch, CURLOPT_MIMEPOST, $mime);');
|
|
111
112
|
}
|
|
112
113
|
else if (normalizedRequest.postData.mimeType === 'application/x-www-form-urlencoded' &&
|
|
113
114
|
normalizedRequest.postData.params) {
|
|
@@ -139,6 +140,9 @@ export const phpCurl = {
|
|
|
139
140
|
// Execute and close
|
|
140
141
|
parts.push('');
|
|
141
142
|
parts.push('curl_exec($ch);');
|
|
143
|
+
if (hasMultipartMimeBody) {
|
|
144
|
+
parts.push('curl_mime_free($mime);');
|
|
145
|
+
}
|
|
142
146
|
parts.push('');
|
|
143
147
|
parts.push('curl_close($ch);');
|
|
144
148
|
return parts.join('\n').replace(/\n\n\n/g, '\n\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestsLike.d.ts","sourceRoot":"","sources":["../../../src/plugins/python/requestsLike.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AA0B7E,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,EAC7B,aAAa,CAAC,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"requestsLike.d.ts","sourceRoot":"","sources":["../../../src/plugins/python/requestsLike.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AA0B7E,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,EAC7B,aAAa,CAAC,EAAE,mBAAmB,UA2JpC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { reduceQueryParams } from '../../libs/http.js';
|
|
1
|
+
import { accumulateRepeatedValue, reduceQueryParams } from '../../libs/http.js';
|
|
2
2
|
const LENGTH_CONSIDERED_AS_SHORT = 40;
|
|
3
3
|
// Function to convert JavaScript boolean and null values to Python equivalents
|
|
4
4
|
function convertToPythonSyntax(str) {
|
|
@@ -86,7 +86,7 @@ export function requestsLikeGenerate(clientVar, request, configuration) {
|
|
|
86
86
|
files.push(`(${name}, (None, ${value}, ${contentType}))`);
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
|
-
formData
|
|
89
|
+
accumulateRepeatedValue(formData, param.name, param.value);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
});
|
|
@@ -98,7 +98,11 @@ export function requestsLikeGenerate(clientVar, request, configuration) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
else if (mimeType === 'application/x-www-form-urlencoded' && params) {
|
|
101
|
-
|
|
101
|
+
const formData = {};
|
|
102
|
+
params.forEach((param) => {
|
|
103
|
+
accumulateRepeatedValue(formData, param.name, param.value ?? '');
|
|
104
|
+
});
|
|
105
|
+
options.data = formData;
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
108
|
// Format all parameters
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shell/curl/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"curl.d.ts","sourceRoot":"","sources":["../../../../src/plugins/shell/curl/curl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAIpD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAkIvB,CAAA"}
|
|
@@ -22,9 +22,7 @@ export const shellCurl = {
|
|
|
22
22
|
normalizedRequest.queryString
|
|
23
23
|
.map((param) => {
|
|
24
24
|
// Ensure both name and value are fully URI encoded
|
|
25
|
-
|
|
26
|
-
const encodedValue = encodeURIComponent(param.value);
|
|
27
|
-
return `${encodedName}=${encodedValue}`;
|
|
25
|
+
return `${param.name}=${param.value}`;
|
|
28
26
|
})
|
|
29
27
|
.join('&')
|
|
30
28
|
: '';
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
10
10
|
"directory": "packages/snippetz"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.8.0",
|
|
13
13
|
"engines": {
|
|
14
14
|
"node": ">=22"
|
|
15
15
|
},
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
"dependencies": {
|
|
231
231
|
"js-base64": "^3.7.8",
|
|
232
232
|
"stringify-object": "^6.0.0",
|
|
233
|
-
"@scalar/types": "0.
|
|
233
|
+
"@scalar/types": "0.8.0"
|
|
234
234
|
},
|
|
235
235
|
"devDependencies": {
|
|
236
236
|
"@types/stringify-object": "^4.0.5",
|