mirror of
https://github.com/curlconverter/curlconverter.git
synced 2022-05-22 02:35:29 +03:00
support --form, --proxy and --upload-file for fetch() (#395)
This commit is contained in:
committed by
GitHub
parent
dda866a741
commit
247a741ed6
@@ -99,20 +99,20 @@ export const _toCFML = (
|
||||
|
||||
if (request.data || request.multipartUploads) {
|
||||
if (request.multipartUploads) {
|
||||
for (const { name, content, contentFile } of request.multipartUploads) {
|
||||
if (contentFile) {
|
||||
for (const m of request.multipartUploads) {
|
||||
if ("contentFile" in m) {
|
||||
cfmlCode +=
|
||||
'httpService.addParam(type="file", name="' +
|
||||
quote(name) +
|
||||
quote(m.name) +
|
||||
'", file="#expandPath("' +
|
||||
quote(contentFile) +
|
||||
quote(m.contentFile) +
|
||||
'")#");\n';
|
||||
} else {
|
||||
cfmlCode +=
|
||||
'httpService.addParam(type="formfield", name="' +
|
||||
quote(name) +
|
||||
quote(m.name) +
|
||||
'", value="' +
|
||||
quote(content as string) +
|
||||
quote(m.content) +
|
||||
'");\n';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,11 +129,12 @@ function getFormDataString(request: Request): string {
|
||||
|
||||
let fileArgs: string[] | string = [];
|
||||
let dataArgs: string[] | string = [];
|
||||
for (const { name, content, contentFile } of request.multipartUploads) {
|
||||
if (contentFile) {
|
||||
fileArgs.push(` {:file, ~s|${contentFile}|}`);
|
||||
for (const m of request.multipartUploads) {
|
||||
if ("contentFile" in m) {
|
||||
// TODO: quote
|
||||
fileArgs.push(` {:file, ~s|${m.contentFile}|}`);
|
||||
} else {
|
||||
dataArgs.push(` {${repr(name)}, ${repr(content as string)}}`);
|
||||
dataArgs.push(` {${repr(m.name)}, ${repr(m.content)}}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import * as util from "../../util.js";
|
||||
import { repr, bySecondElem } from "./javascript.js";
|
||||
import type { Request, Warnings } from "../../util.js";
|
||||
|
||||
import jsesc from "jsesc";
|
||||
|
||||
const supportedArgs = new Set([
|
||||
"url",
|
||||
"request",
|
||||
@@ -27,20 +26,6 @@ const supportedArgs = new Set([
|
||||
"max-time",
|
||||
]);
|
||||
|
||||
const repr = (value: string | object, indentLevel?: number): string => {
|
||||
const escaped = jsesc(value, {
|
||||
quotes: "single",
|
||||
minimal: false,
|
||||
compact: false,
|
||||
indent: " ",
|
||||
indentLevel: indentLevel ? indentLevel : 0,
|
||||
});
|
||||
if (typeof value === "string") {
|
||||
return "'" + escaped + "'";
|
||||
}
|
||||
return escaped;
|
||||
};
|
||||
|
||||
// TODO: @
|
||||
const _getDataString = (request: Request): [string | null, string | null] => {
|
||||
if (!request.data) {
|
||||
@@ -164,15 +149,23 @@ const buildConfigObject = (
|
||||
code += " // data: " + commentedOutDataString + ",\n";
|
||||
}
|
||||
code += " data: " + dataString + ",\n";
|
||||
|
||||
// OPTIONS is the only other http method that sends data
|
||||
if (method !== "options") {
|
||||
warnings.push([
|
||||
"no-data-method",
|
||||
"axios doesn't send data: with " + method + " requests",
|
||||
]);
|
||||
}
|
||||
} else if (request.multipartUploads) {
|
||||
code += " data: form,\n";
|
||||
}
|
||||
// the only other http method that sends data
|
||||
if (method !== "options") {
|
||||
warnings.push([
|
||||
"bad-method",
|
||||
"axios doesn't send data: with " + method + " requests",
|
||||
]);
|
||||
|
||||
if (method !== "options") {
|
||||
warnings.push([
|
||||
"no-data-method",
|
||||
"axios doesn't send data: with " + method + " requests",
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,24 +260,20 @@ export const _toNodeAxios = (
|
||||
if (request.multipartUploads) {
|
||||
imports.add(["FormData", "form-data"]);
|
||||
code += "const form = new FormData();\n";
|
||||
for (const {
|
||||
name,
|
||||
filename,
|
||||
content,
|
||||
contentFile,
|
||||
} of request.multipartUploads) {
|
||||
code += "form.append(" + repr(name) + ", ";
|
||||
if (contentFile === "-") {
|
||||
code += "fs.readFileSync(0).toString()";
|
||||
imports.add(["fs", "fs"]);
|
||||
} else if (contentFile) {
|
||||
code += "fs.readFileSync(" + repr(contentFile) + ")";
|
||||
for (const m of request.multipartUploads) {
|
||||
code += "form.append(" + repr(m.name) + ", ";
|
||||
if ("contentFile" in m) {
|
||||
imports.add(["fs", "fs"]);
|
||||
if (m.contentFile === "-") {
|
||||
code += "fs.readFileSync(0).toString()";
|
||||
} else {
|
||||
code += "fs.readFileSync(" + repr(m.contentFile) + ")";
|
||||
}
|
||||
if ("filename" in m && m.filename) {
|
||||
code += ", " + repr(m.filename);
|
||||
}
|
||||
} else {
|
||||
code += repr(content as string);
|
||||
}
|
||||
if (filename && filename !== name) {
|
||||
code += ", " + repr(filename);
|
||||
code += repr(m.content);
|
||||
}
|
||||
code += ");\n";
|
||||
}
|
||||
@@ -384,8 +373,6 @@ export const _toNodeAxios = (
|
||||
|
||||
code += ");\n";
|
||||
|
||||
const bySecondElem = (a: [string, string], b: [string, string]): number =>
|
||||
a[1].localeCompare(b[1]);
|
||||
for (const [varName, imp] of Array.from(imports).sort(bySecondElem)) {
|
||||
importCode += "const " + varName + " = require(" + repr(imp) + ");\n";
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { Request } from "../../util.js";
|
||||
|
||||
import jsesc from "jsesc";
|
||||
|
||||
const supportedArgs = new Set([
|
||||
const javaScriptSupportedArgs = new Set([
|
||||
"url",
|
||||
"request",
|
||||
"user-agent",
|
||||
@@ -16,108 +16,315 @@ const supportedArgs = new Set([
|
||||
"data-urlencode",
|
||||
"json",
|
||||
"referer",
|
||||
// "form",
|
||||
// "form-string",
|
||||
"form",
|
||||
"form-string",
|
||||
"get",
|
||||
"header",
|
||||
"head",
|
||||
"no-head",
|
||||
"user",
|
||||
"upload-file",
|
||||
]);
|
||||
|
||||
const nodeSupportedArgs = new Set([
|
||||
"url",
|
||||
"request",
|
||||
"user-agent",
|
||||
"cookie",
|
||||
"data",
|
||||
"data-raw",
|
||||
"data-ascii",
|
||||
"data-binary",
|
||||
"data-urlencode",
|
||||
"json",
|
||||
"referer",
|
||||
"form",
|
||||
"form-string",
|
||||
"get",
|
||||
"header",
|
||||
"head",
|
||||
"no-head",
|
||||
"user",
|
||||
"upload-file",
|
||||
"proxy",
|
||||
]);
|
||||
|
||||
export const repr = (value: string | object, indentLevel?: number): string => {
|
||||
const escaped = jsesc(value, {
|
||||
quotes: "single",
|
||||
minimal: false,
|
||||
compact: false,
|
||||
indent: " ",
|
||||
indentLevel: indentLevel ? indentLevel : 0,
|
||||
});
|
||||
if (typeof value === "string") {
|
||||
return "'" + escaped + "'";
|
||||
}
|
||||
return escaped;
|
||||
};
|
||||
|
||||
export const bySecondElem = (
|
||||
a: [string, string],
|
||||
b: [string, string]
|
||||
): number => a[1].localeCompare(b[1]);
|
||||
|
||||
const getDataString = (request: Request): [string, string | null] => {
|
||||
if (!request.data) {
|
||||
return ["", null];
|
||||
}
|
||||
const originalStringRepr = repr(request.data);
|
||||
|
||||
const contentType = util.getContentType(request);
|
||||
if (contentType === "application/json") {
|
||||
try {
|
||||
const parsed = JSON.parse(request.data);
|
||||
// Only bother for arrays and {}
|
||||
if (typeof parsed !== "object" || parsed === null) {
|
||||
return [originalStringRepr, null];
|
||||
}
|
||||
const roundtrips = JSON.stringify(parsed) === request.data;
|
||||
const jsonAsJavaScript = repr(parsed, 1);
|
||||
|
||||
const dataString = "JSON.stringify(" + jsonAsJavaScript + ")";
|
||||
return [dataString, roundtrips ? null : originalStringRepr];
|
||||
} catch {
|
||||
return [originalStringRepr, null];
|
||||
}
|
||||
}
|
||||
if (contentType === "application/x-www-form-urlencoded") {
|
||||
try {
|
||||
const query = util.parseQueryString(request.data);
|
||||
const queryDict = query[1];
|
||||
if (
|
||||
queryDict &&
|
||||
Object.values(queryDict).every((v) => typeof v === "string")
|
||||
) {
|
||||
// Technically node-fetch sends
|
||||
// application/x-www-form-urlencoded;charset=utf-8
|
||||
// TODO: handle repeated content-type header
|
||||
if (
|
||||
util.getHeader(request, "content-type") ===
|
||||
"application/x-www-form-urlencoded"
|
||||
) {
|
||||
util.deleteHeader(request, "content-type");
|
||||
}
|
||||
// TODO: check roundtrip, add a comment
|
||||
return ["new URLSearchParams(" + repr(queryDict, 1) + ")", null];
|
||||
}
|
||||
return [originalStringRepr, null];
|
||||
} catch {
|
||||
return [originalStringRepr, null];
|
||||
}
|
||||
}
|
||||
return [originalStringRepr, null];
|
||||
};
|
||||
|
||||
export const _toJavaScriptOrNode = (
|
||||
request: Request,
|
||||
warnings: Warnings,
|
||||
isNode: boolean
|
||||
): [string, Warnings] => {
|
||||
const fetchImports: Set<string> = new Set();
|
||||
const imports: Set<[string, string]> = new Set();
|
||||
|
||||
let code = "";
|
||||
|
||||
if (request.multipartUploads) {
|
||||
if (isNode) {
|
||||
fetchImports.add("FormData");
|
||||
}
|
||||
code += "const form = new FormData();\n";
|
||||
for (const m of request.multipartUploads) {
|
||||
// TODO: use .set() if all names are unique?
|
||||
code += "form.append(" + repr(m.name) + ", ";
|
||||
if ("contentFile" in m) {
|
||||
if (isNode) {
|
||||
if (m.contentFile === "-") {
|
||||
imports.add(["fs", "fs"]);
|
||||
code += "fs.readFileSync(0).toString()";
|
||||
if (m.filename) {
|
||||
code += ", " + repr(m.filename);
|
||||
}
|
||||
} else {
|
||||
fetchImports.add("fileFromSync");
|
||||
// TODO: do this in a way that doesn't set filename="" if we don't have filename
|
||||
code += "fileFromSync(" + repr(m.contentFile) + ")";
|
||||
}
|
||||
} else {
|
||||
// TODO: does the second argument get sent as filename="" ?
|
||||
code += "File(['<data goes here>'], " + repr(m.contentFile) + ")";
|
||||
// TODO: (massive todo) we could read the file if we're running in the command line
|
||||
warnings.push([
|
||||
"--form",
|
||||
"you can't read a file for --form/-F in the browser",
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
code += repr(m.content);
|
||||
}
|
||||
code += ");\n";
|
||||
}
|
||||
code += "\n";
|
||||
}
|
||||
|
||||
// Can delete content-type header
|
||||
const [dataString, commentedOutDataString] = getDataString(request);
|
||||
|
||||
code += "fetch(" + repr(request.url);
|
||||
|
||||
const method = request.method.toLowerCase();
|
||||
|
||||
if (
|
||||
method !== "get" ||
|
||||
(request.headers && request.headers.length) ||
|
||||
request.auth ||
|
||||
request.data ||
|
||||
request.multipartUploads ||
|
||||
(isNode && request.proxy)
|
||||
) {
|
||||
code += ", {\n";
|
||||
|
||||
if (method !== "get") {
|
||||
// TODO: If you pass a weird method to fetch() it won't uppercase it
|
||||
// const methods = []
|
||||
// const method = methods.includes(request.method.toLowerCase()) ? request.method.toUpperCase() : request.method
|
||||
code += " method: " + repr(request.method) + ",\n";
|
||||
}
|
||||
|
||||
if ((request.headers && request.headers.length) || request.auth) {
|
||||
code += " headers: {\n";
|
||||
for (const [headerName, headerValue] of request.headers || []) {
|
||||
code +=
|
||||
" " +
|
||||
repr(headerName) +
|
||||
": " +
|
||||
repr(headerValue || "") +
|
||||
",\n";
|
||||
}
|
||||
if (request.auth) {
|
||||
// TODO: if -H 'Authorization:' is passed, don't set this
|
||||
const [user, password] = request.auth;
|
||||
code +=
|
||||
" 'Authorization': 'Basic ' + btoa(" +
|
||||
repr(user + ":" + password) +
|
||||
"),\n";
|
||||
}
|
||||
|
||||
if (code.endsWith(",\n")) {
|
||||
code = code.slice(0, -2);
|
||||
code += "\n";
|
||||
}
|
||||
code += " },\n";
|
||||
}
|
||||
|
||||
if (request.data) {
|
||||
if (commentedOutDataString) {
|
||||
code += " // body: " + commentedOutDataString + ",\n";
|
||||
}
|
||||
code += " body: " + dataString + ",\n";
|
||||
} else if (request.multipartUploads) {
|
||||
code += " body: form,\n";
|
||||
} else if (request.uploadFile) {
|
||||
if (isNode) {
|
||||
fetchImports.add("fileFromSync");
|
||||
code += " body: fileFromSync(" + repr(request.uploadFile) + "),\n";
|
||||
} else {
|
||||
code +=
|
||||
" body: File(['<data goes here>'], " +
|
||||
repr(request.uploadFile) +
|
||||
"),\n";
|
||||
warnings.push([
|
||||
"--form",
|
||||
"you can't read a file for --upload-file/-F in the browser",
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isNode && request.proxy) {
|
||||
// TODO: do this parsing in utils.ts
|
||||
const proxy = request.proxy.includes("://")
|
||||
? request.proxy
|
||||
: "http://" + request.proxy;
|
||||
// TODO: could be more accurate
|
||||
let [protocol] = proxy.split(/:\/\/(.*)/s, 2);
|
||||
protocol = protocol.toLowerCase();
|
||||
|
||||
if (!protocol) {
|
||||
protocol = "http";
|
||||
}
|
||||
if (protocol === "socks") {
|
||||
protocol = "socks4";
|
||||
proxy.replace(/^socks/, "socks4");
|
||||
}
|
||||
|
||||
switch (protocol) {
|
||||
case "socks4":
|
||||
case "socks5":
|
||||
case "socks5h":
|
||||
case "socks4a":
|
||||
imports.add(["{ SocksProxyAgent }", "socks-proxy-agent"]);
|
||||
code += " agent: new SocksProxyAgent(" + repr(proxy) + "),\n";
|
||||
break;
|
||||
case "http":
|
||||
case "https":
|
||||
imports.add(["HttpsProxyAgent", "https-proxy-agent"]);
|
||||
code += " agent: new HttpsProxyAgent(" + repr(proxy) + "),\n";
|
||||
break;
|
||||
default:
|
||||
warnings.push([
|
||||
"--proxy",
|
||||
"failed to parse --proxy/-x or unknown protocol: " + protocol,
|
||||
]);
|
||||
break;
|
||||
// default:
|
||||
// throw new CCError('Unsupported proxy scheme for ' + repr(request.proxy))
|
||||
}
|
||||
}
|
||||
|
||||
if (code.endsWith(",\n")) {
|
||||
code = code.slice(0, -2);
|
||||
}
|
||||
code += "\n}";
|
||||
}
|
||||
code += ");";
|
||||
|
||||
// TODO: generate some code for the output, like .json() if 'Accept': 'application/json'
|
||||
|
||||
let importCode = "";
|
||||
if (isNode) {
|
||||
importCode += "import fetch";
|
||||
if (fetchImports.size) {
|
||||
importCode += ", { " + Array.from(fetchImports).sort().join(", ") + " }";
|
||||
}
|
||||
importCode += " from 'node-fetch';\n";
|
||||
}
|
||||
if (imports.size) {
|
||||
for (const [varName, imp] of Array.from(imports).sort(bySecondElem)) {
|
||||
importCode += "import " + varName + " from " + repr(imp) + ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (importCode) {
|
||||
code = importCode + "\n" + code;
|
||||
}
|
||||
return [code + "\n", warnings];
|
||||
};
|
||||
|
||||
export const _toJavaScript = (
|
||||
request: Request,
|
||||
warnings?: Warnings
|
||||
): [string, Warnings] => {
|
||||
warnings = warnings || [];
|
||||
let jsFetchCode = "";
|
||||
|
||||
if (request.data) {
|
||||
// escape single quotes if there are any in there
|
||||
if (request.data.indexOf("'") > -1) {
|
||||
request.data = jsesc(request.data);
|
||||
}
|
||||
|
||||
try {
|
||||
JSON.parse(request.data);
|
||||
|
||||
if (!request.headers) {
|
||||
request.headers = [];
|
||||
}
|
||||
|
||||
if (!util.hasHeader(request, "Content-Type")) {
|
||||
request.headers.push([
|
||||
"Content-Type",
|
||||
"application/json; charset=UTF-8",
|
||||
]);
|
||||
}
|
||||
|
||||
request.data = "JSON.stringify(" + request.data + ")";
|
||||
} catch {
|
||||
request.data = "'" + request.data + "'";
|
||||
}
|
||||
}
|
||||
|
||||
jsFetchCode += "fetch('" + request.url + "'";
|
||||
|
||||
if (
|
||||
request.method.toUpperCase() !== "GET" ||
|
||||
request.headers ||
|
||||
request.auth ||
|
||||
request.data
|
||||
) {
|
||||
jsFetchCode += ", {\n";
|
||||
|
||||
if (request.method.toUpperCase() !== "GET") {
|
||||
// TODO: If you pass a weird method to fetch() it won't uppercase it
|
||||
// const methods = []
|
||||
// const method = methods.includes(request.method.toLowerCase()) ? request.method.toUpperCase() : request.method
|
||||
jsFetchCode += " method: '" + request.method.toUpperCase() + "'";
|
||||
}
|
||||
|
||||
if (request.headers || request.auth) {
|
||||
if (request.method.toUpperCase() !== "GET") {
|
||||
jsFetchCode += ",\n";
|
||||
}
|
||||
jsFetchCode += " headers: {\n";
|
||||
const headerCount = request.headers ? request.headers.length : 0;
|
||||
let i = 0;
|
||||
for (const [headerName, headerValue] of request.headers || []) {
|
||||
jsFetchCode += " '" + headerName + "': '" + headerValue + "'";
|
||||
if (i < headerCount - 1 || request.auth) {
|
||||
jsFetchCode += ",\n";
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (request.auth) {
|
||||
const [user, password] = request.auth;
|
||||
jsFetchCode +=
|
||||
" 'Authorization': 'Basic ' + btoa('" +
|
||||
user +
|
||||
":" +
|
||||
password +
|
||||
"')";
|
||||
}
|
||||
|
||||
jsFetchCode += "\n }";
|
||||
}
|
||||
|
||||
if (request.data) {
|
||||
jsFetchCode += ",\n body: " + request.data;
|
||||
}
|
||||
|
||||
jsFetchCode += "\n}";
|
||||
}
|
||||
|
||||
jsFetchCode += ");";
|
||||
|
||||
return [jsFetchCode + "\n", warnings];
|
||||
return _toJavaScriptOrNode(request, warnings, false);
|
||||
};
|
||||
|
||||
export const toJavaScriptWarn = (
|
||||
curlCommand: string | string[]
|
||||
): [string, Warnings] => {
|
||||
const [request, warnings] = util.parseCurlCommand(curlCommand, supportedArgs);
|
||||
const [request, warnings] = util.parseCurlCommand(
|
||||
curlCommand,
|
||||
javaScriptSupportedArgs
|
||||
);
|
||||
return _toJavaScript(request, warnings);
|
||||
};
|
||||
|
||||
@@ -125,21 +332,21 @@ export const toJavaScript = (curlCommand: string | string[]): string => {
|
||||
return toJavaScriptWarn(curlCommand)[0];
|
||||
};
|
||||
|
||||
const importStatement = "var fetch = require('node-fetch');\n\n";
|
||||
|
||||
export const _toNode = (
|
||||
request: Request,
|
||||
warnings?: Warnings
|
||||
): [string, Warnings] => {
|
||||
let jsCode;
|
||||
[jsCode, warnings] = _toJavaScript(request, warnings);
|
||||
return [importStatement + jsCode, warnings];
|
||||
warnings = warnings || [];
|
||||
return _toJavaScriptOrNode(request, warnings, true);
|
||||
};
|
||||
|
||||
export const toNodeWarn = (
|
||||
curlCommand: string | string[]
|
||||
): [string, Warnings] => {
|
||||
const [request, warnings] = util.parseCurlCommand(curlCommand, supportedArgs);
|
||||
const [request, warnings] = util.parseCurlCommand(
|
||||
curlCommand,
|
||||
nodeSupportedArgs
|
||||
);
|
||||
return _toNode(request, warnings);
|
||||
};
|
||||
export const toNode = (curlCommand: string | string[]): string => {
|
||||
|
||||
@@ -93,6 +93,7 @@ export const toNodeRequestWarn = (
|
||||
curlCommand: string | string[]
|
||||
): [string, Warnings] => {
|
||||
const [request, warnings] = util.parseCurlCommand(curlCommand, supportedArgs);
|
||||
warnings.unshift(["node-request", "the request package is deprecated"]);
|
||||
return _toNodeRequest(request, warnings);
|
||||
};
|
||||
export const toNodeRequest = (curlCommand: string | string[]): string => {
|
||||
|
||||
@@ -105,11 +105,12 @@ function getFilesString(
|
||||
data: {},
|
||||
};
|
||||
|
||||
for (const { name, content, contentFile } of request.multipartUploads) {
|
||||
if (contentFile) {
|
||||
data.files[name] = contentFile;
|
||||
// TODO: this isn't great.
|
||||
for (const m of request.multipartUploads) {
|
||||
if ("contentFile" in m) {
|
||||
data.files[m.name] = m.contentFile;
|
||||
} else {
|
||||
data.data[name] = content as string;
|
||||
data.data[m.name] = m.content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -109,17 +109,17 @@ const prepareMultipartUploads = (request: Request): string | null => {
|
||||
let response = null;
|
||||
if (request.multipartUploads) {
|
||||
const params: [string, string][] = [];
|
||||
for (const { name, content, contentFile } of request.multipartUploads) {
|
||||
const value = contentFile ? "@" + contentFile : (content as string); // TODO: something nicer
|
||||
for (const m of request.multipartUploads) {
|
||||
const value = "contentFile" in m ? "@" + m.contentFile : m.content; // TODO: something nicer
|
||||
const fileProvider = prepareDataProvider(
|
||||
value,
|
||||
null,
|
||||
"",
|
||||
1,
|
||||
true,
|
||||
!contentFile
|
||||
!("contentFile" in m)
|
||||
);
|
||||
params.push([repr(name), fileProvider as string]); // TODO: can this be not a string?
|
||||
params.push([repr(m.name), fileProvider as string]); // TODO: can this be not a string?
|
||||
}
|
||||
response = callFunction("body", "MultipartFormProvider", params);
|
||||
}
|
||||
|
||||
@@ -98,21 +98,17 @@ export const _toPhp = (
|
||||
let requestDataCode = "";
|
||||
if (request.multipartUploads) {
|
||||
requestDataCode = "[\n";
|
||||
for (const { name, content, contentFile } of request.multipartUploads) {
|
||||
if (contentFile) {
|
||||
for (const m of request.multipartUploads) {
|
||||
if ("contentFile" in m) {
|
||||
requestDataCode +=
|
||||
" '" +
|
||||
quote(name) +
|
||||
quote(m.name) +
|
||||
"' => new CURLFile('" +
|
||||
quote(contentFile) +
|
||||
quote(m.contentFile) +
|
||||
"'),\n";
|
||||
} else {
|
||||
requestDataCode +=
|
||||
" '" +
|
||||
quote(name) +
|
||||
"' => '" +
|
||||
quote(content as string) +
|
||||
"',\n";
|
||||
" '" + quote(m.name) + "' => '" + quote(m.content) + "',\n";
|
||||
}
|
||||
}
|
||||
requestDataCode += "]";
|
||||
|
||||
@@ -551,26 +551,23 @@ function getFilesString(request: Request): [string, boolean] {
|
||||
// (name, open(filename/contentFile))
|
||||
// (name, (filename, open(contentFile))
|
||||
// (name, (filename, open(contentFile), contentType, headers)) // this isn't parsed from --form yet
|
||||
const { filename, content, contentFile } = m;
|
||||
const name = m.name ? repr(m.name) : "None";
|
||||
const sentFilename = filename ? repr(filename) : "None";
|
||||
if (contentFile) {
|
||||
if (contentFile === "-") {
|
||||
const sentFilename =
|
||||
"filename" in m && m.filename ? repr(m.filename) : "None";
|
||||
if ("contentFile" in m) {
|
||||
if (m.contentFile === "-") {
|
||||
// TODO: use piped stdin if we have it
|
||||
usesStdin = true;
|
||||
return [name, "(" + sentFilename + ", sys.stdin.buffer.read())"];
|
||||
} else if (contentFile === filename) {
|
||||
return [name, "open(" + repr(contentFile) + ", 'rb')"];
|
||||
} else if (m.contentFile === m.filename) {
|
||||
return [name, "open(" + repr(m.contentFile) + ", 'rb')"];
|
||||
}
|
||||
return [
|
||||
name,
|
||||
"(" + sentFilename + ", open(" + repr(contentFile) + ", 'rb'))",
|
||||
"(" + sentFilename + ", open(" + repr(m.contentFile) + ", 'rb'))",
|
||||
];
|
||||
}
|
||||
// We should always either have .content or .contentFile
|
||||
if (filename && name === filename) {
|
||||
return [name, repr(content as string)];
|
||||
}
|
||||
return [name, "(" + sentFilename + ", " + repr(content as string) + ")"];
|
||||
return [name, "(" + sentFilename + ", " + repr(m.content) + ")"];
|
||||
});
|
||||
|
||||
const multipartUploadsAsDict = Object.fromEntries(multipartUploads);
|
||||
|
||||
@@ -76,14 +76,13 @@ function getFilesString(request: Request): string | undefined {
|
||||
let filesString = "files = list(\n";
|
||||
filesString += request.multipartUploads
|
||||
.map((m) => {
|
||||
const { name, content, contentFile } = m;
|
||||
let fileParam;
|
||||
if (contentFile) {
|
||||
if ("contentFile" in m) {
|
||||
// filesString += ' ' + reprn(multipartKey) + ' (' + repr(fileName) + ', upload_file(' + repr(fileName) + '))'
|
||||
fileParam =
|
||||
" " + reprn(name) + " = upload_file(" + repr(contentFile) + ")";
|
||||
" " + reprn(m.name) + " = upload_file(" + repr(m.contentFile) + ")";
|
||||
} else {
|
||||
fileParam = " " + reprn(name) + " = " + repr(content as string) + "";
|
||||
fileParam = " " + reprn(m.name) + " = " + repr(m.content) + "";
|
||||
}
|
||||
return fileParam;
|
||||
})
|
||||
|
||||
@@ -74,11 +74,10 @@ export const _toRust = (
|
||||
if (request.multipartUploads) {
|
||||
lines.push(indent("let form = multipart::Form::new()"));
|
||||
const parts = request.multipartUploads.map((m) => {
|
||||
const { name, content, contentFile } = m;
|
||||
if (contentFile) {
|
||||
return indent(`.file("${name}", "${quote(contentFile)}")?`, 2);
|
||||
if ("contentFile" in m) {
|
||||
return indent(`.file("${m.name}", "${quote(m.contentFile)}")?`, 2);
|
||||
}
|
||||
return indent(`.text("${name}", "${quote(content as string)}")`, 2);
|
||||
return indent(`.text("${m.name}", "${quote(m.content)}")`, 2);
|
||||
});
|
||||
parts[parts.length - 1] += ";";
|
||||
lines.push(...parts, "");
|
||||
|
||||
20
src/util.ts
20
src/util.ts
@@ -114,12 +114,9 @@ interface Request {
|
||||
headers?: Headers;
|
||||
stdin?: string;
|
||||
input?: string;
|
||||
multipartUploads?: {
|
||||
multipartUploads?: ({
|
||||
name: string;
|
||||
filename?: string;
|
||||
content?: string;
|
||||
contentFile?: string;
|
||||
}[];
|
||||
} & ({ content: string } | { contentFile: string; filename?: string }))[];
|
||||
auth?: [string, string];
|
||||
cookies?: Cookies;
|
||||
compressed?: boolean;
|
||||
@@ -1571,16 +1568,17 @@ function buildRequest(parsedArguments: ParsedArguments): Request {
|
||||
const [name, value] = multipartArgument.value.split(/=(.*)/s, 2);
|
||||
const isString = multipartArgument.type === "string";
|
||||
|
||||
let filename, content, contentFile;
|
||||
if (!isString && value.charAt(0) === "@") {
|
||||
filename = value.slice(1);
|
||||
contentFile = filename;
|
||||
const contentFile = value.slice(1);
|
||||
const filename = contentFile;
|
||||
request.multipartUploads.push({ name, contentFile, filename });
|
||||
} else if (!isString && value.charAt(0) === "<") {
|
||||
contentFile = value.slice(1);
|
||||
const contentFile = value.slice(1);
|
||||
request.multipartUploads.push({ name, contentFile });
|
||||
} else {
|
||||
content = value;
|
||||
const content = value;
|
||||
request.multipartUploads.push({ name, content });
|
||||
}
|
||||
request.multipartUploads.push({ name, filename, content, contentFile });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
3
test/fixtures/javascript/delete.js
generated
vendored
Normal file
3
test/fixtures/javascript/delete.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fetch('http://localhost:28139/page', {
|
||||
method: 'DELETE'
|
||||
});
|
||||
7
test/fixtures/javascript/delete_content_type.js
generated
vendored
Normal file
7
test/fixtures/javascript/delete_content_type.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fetch('localhost:28139', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({})
|
||||
});
|
||||
8
test/fixtures/javascript/get_charles_syntax.js
generated
vendored
Normal file
8
test/fixtures/javascript/get_charles_syntax.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fetch('http://localhost:28139/?format=json&', {
|
||||
headers: {
|
||||
'Host': 'api.ipify.org',
|
||||
'Accept': '*/*',
|
||||
'User-Agent': 'GiftTalk/2.7.2 (iPhone; iOS 9.0.2; Scale/3.00)',
|
||||
'Accept-Language': 'en-CN;q=1, zh-Hans-CN;q=0.9'
|
||||
}
|
||||
});
|
||||
1
test/fixtures/javascript/get_complex_url_params.js
generated
vendored
Normal file
1
test/fixtures/javascript/get_complex_url_params.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
fetch('https://localhost:28139/house-sitting/?page=1&available=&available=1&location=0&city%5Bid%5D=0&city%5Blocality%5D=&city%5Blocality_text%5D=&city%5Badministrative_area_level_2%5D=&city%5Badministrative_area_level_2_text%5D=&city%5Badministrative_area_level_1%5D=&city%5Badministrative_area_level_1_text%5D=&city%5Bcountry%5D=&city%5Bcountry_text%5D=&city%5Blatitude%5D=&city%5Blongitude%5D=&city%5Bzoom%5D=&city%5Bname%5D=®ion%5Bid%5D=0®ion%5Blocality%5D=®ion%5Blocality_text%5D=®ion%5Badministrative_area_level_2%5D=®ion%5Badministrative_area_level_2_text%5D=®ion%5Badministrative_area_level_1%5D=®ion%5Badministrative_area_level_1_text%5D=®ion%5Bcountry%5D=®ion%5Bcountry_text%5D=®ion%5Blatitude%5D=®ion%5Blongitude%5D=®ion%5Bzoom%5D=®ion%5Bname%5D=&country=&environment=&population=&period=0&date=2017-03-03&datestart=2017-03-03&dateend=2017-06-24&season=&duration=&isfd=&stopover=');
|
||||
6
test/fixtures/javascript/get_cookie_with_empty_value.js
generated
vendored
Normal file
6
test/fixtures/javascript/get_cookie_with_empty_value.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
fetch('https://localhost:28139/cookies', {
|
||||
headers: {
|
||||
'accept': 'application/json',
|
||||
'Cookie': 'mysamplecookie=someValue; emptycookie=; otherCookie=2'
|
||||
}
|
||||
});
|
||||
5
test/fixtures/javascript/get_header_with_quotes.js
generated
vendored
Normal file
5
test/fixtures/javascript/get_header_with_quotes.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
fetch('http://localhost:28139', {
|
||||
headers: {
|
||||
'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="92"'
|
||||
}
|
||||
});
|
||||
1
test/fixtures/javascript/get_proxy.js
generated
vendored
Normal file
1
test/fixtures/javascript/get_proxy.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
fetch('http://localhost:28139');
|
||||
7
test/fixtures/javascript/get_referer.js
generated
vendored
Normal file
7
test/fixtures/javascript/get_referer.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fetch('http://localhost:28139', {
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'User-Agent': 'SimCity',
|
||||
'Referer': 'https://website.com'
|
||||
}
|
||||
});
|
||||
6
test/fixtures/javascript/get_user_agent.js
generated
vendored
Normal file
6
test/fixtures/javascript/get_user_agent.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
fetch('http://localhost:28139/vc/moviesmagic?p=5&pub=testmovie&tkn=817263812', {
|
||||
headers: {
|
||||
'x-msisdn': 'XXXXXXXXXXXXX',
|
||||
'user-agent': 'Mozilla Android6.1'
|
||||
}
|
||||
});
|
||||
6
test/fixtures/javascript/get_user_agent_alias.js
generated
vendored
Normal file
6
test/fixtures/javascript/get_user_agent_alias.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
fetch('http://localhost:28139/vc/moviesmagic?p=5&pub=testmovie&tkn=817263812', {
|
||||
headers: {
|
||||
'x-msisdn': 'XXXXXXXXXXXXX',
|
||||
'user-agent': 'Mozilla Android6.1'
|
||||
}
|
||||
});
|
||||
2
test/fixtures/javascript/get_with_all_numerical_data.js
generated
vendored
2
test/fixtures/javascript/get_with_all_numerical_data.js
generated
vendored
@@ -4,5 +4,5 @@ fetch('http://localhost:28139/CurlToNode', {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(18233982904)
|
||||
body: '18233982904'
|
||||
});
|
||||
|
||||
5
test/fixtures/javascript/get_with_data.js
generated
vendored
Normal file
5
test/fixtures/javascript/get_with_data.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
fetch('http://localhost:28139/synthetics/api/v3/monitors?test=2&limit=100&w=4', {
|
||||
headers: {
|
||||
'X-Api-Key': '123456789'
|
||||
}
|
||||
});
|
||||
7
test/fixtures/javascript/get_with_data2.js
generated
vendored
Normal file
7
test/fixtures/javascript/get_with_data2.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fetch('http://localhost:28139/v2/alerts_policy_channels.json?policy_id=policy_id&channel_ids=channel_id', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'X-Api-Key': '{admin_api_key}',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
13
test/fixtures/javascript/get_with_form.js
generated
vendored
Normal file
13
test/fixtures/javascript/get_with_form.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
const form = new FormData();
|
||||
form.append('from', 'test@tester.com');
|
||||
form.append('to', 'devs@tester.net');
|
||||
form.append('subject', 'Hello');
|
||||
form.append('text', 'Testing the converter!');
|
||||
|
||||
fetch('http://localhost:28139/v3', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Basic ' + btoa('test:')
|
||||
},
|
||||
body: form
|
||||
});
|
||||
6
test/fixtures/javascript/get_with_header_without_value.js
generated
vendored
Normal file
6
test/fixtures/javascript/get_with_header_without_value.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
fetch('localhost:28139/get', {
|
||||
headers: {
|
||||
'Content-Type': 'text/xml;charset=UTF-8',
|
||||
'getWorkOrderCancel': ''
|
||||
}
|
||||
});
|
||||
3
test/fixtures/javascript/head.js
generated
vendored
Normal file
3
test/fixtures/javascript/head.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fetch('http://localhost:28139/page', {
|
||||
method: 'HEAD'
|
||||
});
|
||||
3
test/fixtures/javascript/head_with_I_option.js
generated
vendored
Normal file
3
test/fixtures/javascript/head_with_I_option.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fetch('http://localhost:28139/page', {
|
||||
method: 'HEAD'
|
||||
});
|
||||
8
test/fixtures/javascript/j_data_priority_than_f.js
generated
vendored
Normal file
8
test/fixtures/javascript/j_data_priority_than_f.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fetch('http://localhost:28139/post', {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams({
|
||||
'data1': 'data1',
|
||||
'data2': 'data2',
|
||||
'data3': 'data3'
|
||||
})
|
||||
});
|
||||
7
test/fixtures/javascript/j_patch_array.js
generated
vendored
Normal file
7
test/fixtures/javascript/j_patch_array.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fetch('http://localhost:28139/patch', {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: 'item[]=1&item[]=2&item[]=3'
|
||||
});
|
||||
7
test/fixtures/javascript/j_patch_file_only.js
generated
vendored
Normal file
7
test/fixtures/javascript/j_patch_file_only.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
const form = new FormData();
|
||||
form.append('file1', File(['<data goes here>'], './fixtures/curl_commands/delete.sh'));
|
||||
|
||||
fetch('http://localhost:28139/patch', {
|
||||
method: 'PATCH',
|
||||
body: form
|
||||
});
|
||||
9
test/fixtures/javascript/j_patch_file_with_data.js
generated
vendored
Normal file
9
test/fixtures/javascript/j_patch_file_with_data.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
const form = new FormData();
|
||||
form.append('file1', File(['<data goes here>'], './fixtures/curl_commands/delete.sh'));
|
||||
form.append('form1', 'form+data+1');
|
||||
form.append('form2', 'form_data_2');
|
||||
|
||||
fetch('http://localhost:28139/patch', {
|
||||
method: 'PATCH',
|
||||
body: form
|
||||
});
|
||||
8
test/fixtures/javascript/j_post_data_wo_verb.js
generated
vendored
Normal file
8
test/fixtures/javascript/j_post_data_wo_verb.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fetch('http://localhost:28139/post', {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams({
|
||||
'data1': 'data1',
|
||||
'data2': 'data2',
|
||||
'data3': 'data3'
|
||||
})
|
||||
});
|
||||
8
test/fixtures/javascript/j_post_form_f.js
generated
vendored
Normal file
8
test/fixtures/javascript/j_post_form_f.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
const form = new FormData();
|
||||
form.append('d1', 'data1');
|
||||
form.append('d2', 'data');
|
||||
|
||||
fetch('http://localhost:28139/post', {
|
||||
method: 'POST',
|
||||
body: form
|
||||
});
|
||||
9
test/fixtures/javascript/multiline_post_with_data.js
generated
vendored
Normal file
9
test/fixtures/javascript/multiline_post_with_data.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
fetch('http://localhost:28139/echo/html/', {
|
||||
headers: {
|
||||
'Origin': 'http://fiddle.jshell.net'
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
'msg1': 'value1',
|
||||
'msg2': 'value2'
|
||||
})
|
||||
});
|
||||
11
test/fixtures/javascript/multipart_post.js
generated
vendored
Normal file
11
test/fixtures/javascript/multipart_post.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
const form = new FormData();
|
||||
form.append('attributes', '{"name":"tigers.jpeg", "parent":{"id":"11446498"}}');
|
||||
form.append('file', File(['<data goes here>'], 'myfile.jpg'));
|
||||
|
||||
fetch('https://localhost:28139/api/2.0/files/content', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Bearer ACCESS_TOKEN'
|
||||
},
|
||||
body: form
|
||||
});
|
||||
12
test/fixtures/javascript/multipart_with_headers.js
generated
vendored
Normal file
12
test/fixtures/javascript/multipart_with_headers.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
const form = new FormData();
|
||||
form.append('attributes', '{"name":"tigers.jpeg", "parent":{"id":"11446498"}}');
|
||||
form.append('file', File(['<data goes here>'], 'myfile.jpg'));
|
||||
|
||||
fetch('https://localhost:28139/api/2.0/files/content', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Bearer ACCESS_TOKEN',
|
||||
'X-Nice': 'Header'
|
||||
},
|
||||
body: form
|
||||
});
|
||||
7
test/fixtures/javascript/multiple_d_post.js
generated
vendored
Normal file
7
test/fixtures/javascript/multiple_d_post.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fetch('https://localhost:28139/webservices/rest.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: 'version=1.2&auth_user=fdgxf&auth_pwd=oxfdscds&json_data={ "operation": "core/get", "class": "Software", "key": "key" }'
|
||||
});
|
||||
17
test/fixtures/javascript/options.js
generated
vendored
Normal file
17
test/fixtures/javascript/options.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
fetch('https://localhost:28139/api/tunein/queue-and-play?deviceSerialNumber=xxx^&deviceType=xxx^&guideId=s56876^&contentType=station^&callSign=^&mediaOwnerCustomerId=xxx', {
|
||||
method: 'OPTIONS',
|
||||
headers: {
|
||||
'Pragma': 'no-cache',
|
||||
'Access-Control-Request-Method': 'POST',
|
||||
'Origin': 'https://alexa.amazon.de',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Language': 'de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',
|
||||
'Accept': '*/*',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Referer': 'https://alexa.amazon.de/spa/index.html',
|
||||
'Connection': 'keep-alive',
|
||||
'DNT': '1',
|
||||
'Access-Control-Request-Headers': 'content-type,csrf'
|
||||
}
|
||||
});
|
||||
20
test/fixtures/javascript/patch.js
generated
vendored
Normal file
20
test/fixtures/javascript/patch.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
fetch('http://localhost:28139/go/api/agents/adb9540a-b954-4571-9d9b-2f330739d4da', {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Accept': 'application/vnd.go.cd.v4+json',
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Basic ' + btoa('username:password')
|
||||
},
|
||||
// body: '{\n "hostname": "agent02.example.com",\n "agent_config_state": "Enabled",\n "resources": ["Java","Linux"],\n "environments": ["Dev"]\n }',
|
||||
body: JSON.stringify({
|
||||
'hostname': 'agent02.example.com',
|
||||
'agent_config_state': 'Enabled',
|
||||
'resources': [
|
||||
'Java',
|
||||
'Linux'
|
||||
],
|
||||
'environments': [
|
||||
'Dev'
|
||||
]
|
||||
})
|
||||
});
|
||||
9
test/fixtures/javascript/post_basic_auth_url_encoded_data.js
generated
vendored
Normal file
9
test/fixtures/javascript/post_basic_auth_url_encoded_data.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
fetch('http://localhost:28139/api/oauth/token/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Basic ' + btoa('foo:bar')
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
'grant_type': 'client_credentials'
|
||||
})
|
||||
});
|
||||
75
test/fixtures/javascript/post_data_binary_with_equals.js
generated
vendored
Normal file
75
test/fixtures/javascript/post_data_binary_with_equals.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
fetch('http://localhost:28139/api/service.svc?action=CreateItem&ID=-37&AC=1', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Cookie': 'X-BackEndCookie=S-1-5-21-1234556-56678-12345-2345=alphanumericstring12345/anotheralphanumericstring12345/scsiAdf/P; ClientId=LoremIupsum; PrivateComputer=true; PBack=0; cadata=bx88rrCBehITlBWSozO2l2hlFGu//JjT1/k6dewX5shV32jANUZSMU6GR+M25B6YpBODEgXzxfIHDnvxNC6SJoaE/d8RWX3uDnbkd+m91jNhMXNSYIRYTJHVFdPG06AE; cadataTTL=NfDhBViTJMUdC+ir+6BYvg==; cadataKey=qUY+OLTD9V14CFK6/CUPyrJWMxl1FFqZFjB8/qcS0/q55eqGvP9bWvX+XuSYVv3hIGAn9QNPhIDK6NP9LwCBdu25f2BUFDUWJruGO8MW02izSWzRUnni00xWQq3Y3nNKvpvO+OIR641BPHVZ0+lzCw2Wt8uzEnryCWAjlleozF/XWjpTN4/AaTmcIjEZUDN+fo4494rD0mADtEHv2gmd5mhLe+iyii/L9nAB3UuiJomwbRbKgy22Tj8cyavmLC4ZaViqW9E102NOLU4FYLgdZVET+mbdg==; cadataIV=bTM88YL1zmz7FsBEB0y3nI2SrdSTy+KLxCpx2FRfIZYFo2spN1IHQMSCT76OXrg79sVPhyqXk+N9rOj6M9KsQl4KqMNVBcoXgp24POpgoTwd4FBmKtAYbd9SDErna3jrMO168ML9PDG18K3CnBf6YG1tsIs0gXOEP9LzHVmUPF7KCKqUFiOiZGWuwmPhl85eo77BbEpVN2JkPnzuQWn6tC0cY4f2cJDlr3Z23SrAUVwwXmgRg2DXfOF5MIEkpwYiiI6sABCD9rsSnE6zTXlvZg33hjiD/ywUV1ZWjI2M/4zBixa4s150+dOnMmvtEFs/nOMnvMJui4PEDlTA==; cadataSig=WL3hB+av7sO3bzjL+Efe5b4exnvQxSInH3U5jDvfnPcttSp0XUF3y/NB573C0CTBYuOH/40smFssXlrKhT9tG2ITivdSIIamOmarmC8XwFOv9qQIFMHofcO/jjRDMqF0qRk7WBAC2FgBQrf2Tvq7wk5IX/JHn6zhlgKALAAqH9L9JNC244etnjj9YNaMDYEHV2M2jVTu3FsELqw1rSSqp0hEBlh+aFBvYCBg5hS1mVI76ZCHZVa0OUejiH2yiZyJIKHUI+Sv0rpU3iiQNtIFmGEdwhoo/rga4s4Dc2UsJLQ8c0yGlZgflYs+7Q5gPr74/mTUin60ej/w3M0roUl3FQ==; UC=d8be544621964f3c9865b3ee872fd432; AppcacheVer=15.0.1236.3:en-usbase; X-OWA-CANARY=VOXQP6xtGkiNnv7E4rFt8TrmclqVFtQI4IJqZflrR7Wz9AMPkMsFoyAlquw1YGsTUxIkVouAcvk.',
|
||||
'Origin': 'https://nih.mail.edu.fr',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'X-EWS-TargetVersion': '2.5',
|
||||
'Accept-Language': 'en-US,en;q=0.8',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
|
||||
'Action': 'CreateItem',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Connection': 'keep-alive',
|
||||
'X-OWA-CANARY': 'VOXQP6xtGkiNnv7E4rFt8TrmclqVFtQI4IJqZflrR7Wz9AMPkMsFoyAlquw1YGsTUxIkVouAcvk.',
|
||||
'X-OWA-ActionName': 'CreateMessageForComposeSend',
|
||||
'X-OWA-ActionId': '-37',
|
||||
'X-OWA-ServiceUnavailableOnTransientError': 'true',
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Accept': '*/*',
|
||||
'Referer': 'https://localhost/api/',
|
||||
'X-OWA-ClientBuildVersion': '15.0.1236.3',
|
||||
'X-OWA-CorrelationId': '2f11f8fb-f6c6-43a5-881d-8a1b242a4e70_148023102251337',
|
||||
'DNT': '1',
|
||||
'X-OWA-ClientBegin': '2016-11-27T07:17:02.513',
|
||||
'X-OWA-Attempt': '1'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
'__type': 'CreateItemJsonRequest:#Exchange',
|
||||
'Header': {
|
||||
'__type': 'JsonRequestHeaders:#Exchange',
|
||||
'RequestServerVersion': 'Exchange2013',
|
||||
'TimeZoneContext': {
|
||||
'__type': 'TimeZoneContext:#Exchange',
|
||||
'TimeZoneDefinition': {
|
||||
'__type': 'TimeZoneDefinitionType:#Exchange',
|
||||
'Id': 'France Standard Time'
|
||||
}
|
||||
}
|
||||
},
|
||||
'Body': {
|
||||
'__type': 'CreateItemRequest:#Exchange',
|
||||
'Items': [
|
||||
{
|
||||
'__type': 'Message:#Exchange',
|
||||
'Subject': 'API',
|
||||
'Body': {
|
||||
'__type': 'BodyContentType:#Exchange',
|
||||
'BodyType': 'HTML',
|
||||
'Value': '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style></head><body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;"><p>API Test for NickC<br></p></body></html>'
|
||||
},
|
||||
'Importance': 'Normal',
|
||||
'From': null,
|
||||
'ToRecipients': [
|
||||
{
|
||||
'Name': 'George LUCAS',
|
||||
'EmailAddress': 'George.LUCAS@nih.mail.edu.fr',
|
||||
'RoutingType': 'SMTP',
|
||||
'MailboxType': 'Mailbox',
|
||||
'OriginalDisplayName': 'George.LUCAS@nih.mail.edu.fr',
|
||||
'SipUri': ' '
|
||||
}
|
||||
],
|
||||
'CcRecipients': [],
|
||||
'BccRecipients': [],
|
||||
'Sensitivity': 'Normal',
|
||||
'IsDeliveryReceiptRequested': false,
|
||||
'IsReadReceiptRequested': false
|
||||
}
|
||||
],
|
||||
'ClientSupportsIrm': true,
|
||||
'OutboundCharset': 'AutoDetect',
|
||||
'MessageDisposition': 'SendAndSaveCopy',
|
||||
'ComposeOperation': 'newMail'
|
||||
}
|
||||
})
|
||||
});
|
||||
2
test/fixtures/javascript/post_escaped_double_quotes_in_single_quotes.js
generated
vendored
2
test/fixtures/javascript/post_escaped_double_quotes_in_single_quotes.js
generated
vendored
@@ -3,5 +3,5 @@ fetch('http://localhost:28139/', {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: 'foo=\"bar\"'
|
||||
body: 'foo=\\"bar\\"'
|
||||
});
|
||||
|
||||
8
test/fixtures/javascript/post_form.js
generated
vendored
Normal file
8
test/fixtures/javascript/post_form.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
const form = new FormData();
|
||||
form.append('username', 'davidwalsh');
|
||||
form.append('password', 'something');
|
||||
|
||||
fetch('http://localhost:28139/post-to-me.php', {
|
||||
method: 'POST',
|
||||
body: form
|
||||
});
|
||||
7
test/fixtures/javascript/post_image.js
generated
vendored
Normal file
7
test/fixtures/javascript/post_image.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
const form = new FormData();
|
||||
form.append('image', File(['<data goes here>'], 'image.jpg'));
|
||||
|
||||
fetch('http://localhost:28139/targetservice', {
|
||||
method: 'POST',
|
||||
body: form
|
||||
});
|
||||
5
test/fixtures/javascript/post_json.js
generated
vendored
5
test/fixtures/javascript/post_json.js
generated
vendored
@@ -4,5 +4,8 @@ fetch('https://localhost:28139', {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ "drink": "coffe" })
|
||||
// body: '{ "drink": "coffe" }',
|
||||
body: JSON.stringify({
|
||||
'drink': 'coffe'
|
||||
})
|
||||
});
|
||||
|
||||
13
test/fixtures/javascript/post_json_multiple_headers.js
generated
vendored
Normal file
13
test/fixtures/javascript/post_json_multiple_headers.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
fetch('https://localhost:28139/rest/login-sessions', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-API-Version': '200'
|
||||
},
|
||||
// body: '{"userName":"username123","password":"password123", "authLoginDomain":"local"}',
|
||||
body: JSON.stringify({
|
||||
'userName': 'username123',
|
||||
'password': 'password123',
|
||||
'authLoginDomain': 'local'
|
||||
})
|
||||
});
|
||||
7
test/fixtures/javascript/post_number.js
generated
vendored
Normal file
7
test/fixtures/javascript/post_number.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fetch('http://localhost:28139', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: '123'
|
||||
});
|
||||
6
test/fixtures/javascript/post_quotes_inside_data.js
generated
vendored
Normal file
6
test/fixtures/javascript/post_quotes_inside_data.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
fetch('localhost:28139', {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams({
|
||||
'field': 'don\'t you like quotes'
|
||||
})
|
||||
});
|
||||
7
test/fixtures/javascript/post_same_field_multiple_times.js
generated
vendored
Normal file
7
test/fixtures/javascript/post_same_field_multiple_times.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fetch('http://localhost:28139/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: 'foo=bar&foo=&foo=barbar'
|
||||
});
|
||||
7
test/fixtures/javascript/post_with_colon_in_header.js
generated
vendored
Normal file
7
test/fixtures/javascript/post_with_colon_in_header.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fetch('http://localhost:28139/endpoint', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'key': 'abcdefg'
|
||||
}
|
||||
});
|
||||
5
test/fixtures/javascript/post_with_data-ascii.js
generated
vendored
5
test/fixtures/javascript/post_with_data-ascii.js
generated
vendored
@@ -11,5 +11,8 @@ fetch('http://localhost:28139/echo/html/', {
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Connection': 'keep-alive'
|
||||
},
|
||||
body: 'msg1=wow&msg2=such'
|
||||
body: new URLSearchParams({
|
||||
'msg1': 'wow',
|
||||
'msg2': 'such'
|
||||
})
|
||||
});
|
||||
|
||||
2
test/fixtures/javascript/post_with_data_binary.js
generated
vendored
2
test/fixtures/javascript/post_with_data_binary.js
generated
vendored
@@ -3,5 +3,5 @@ fetch('http://localhost:28139/post', {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: JSON.stringify({"title":"china1"})
|
||||
body: '{"title":"china1"}'
|
||||
});
|
||||
|
||||
7
test/fixtures/javascript/post_with_data_with_percent_sign.js
generated
vendored
Normal file
7
test/fixtures/javascript/post_with_data_with_percent_sign.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fetch('https://localhost:28139/post', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: 'secret=*%5*!'
|
||||
});
|
||||
15
test/fixtures/javascript/post_with_extra_whitespace.js
generated
vendored
Normal file
15
test/fixtures/javascript/post_with_extra_whitespace.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
const form = new FormData();
|
||||
form.append('files', File(['<data goes here>'], '47.htz'));
|
||||
form.append('name', '47');
|
||||
form.append('oldMediaId', '47');
|
||||
form.append('updateInLayouts', '1');
|
||||
form.append('deleteOldRevisions', '1');
|
||||
|
||||
fetch('http://localhost:28139/api/library', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'accept': 'application/json',
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
body: form
|
||||
});
|
||||
11
test/fixtures/javascript/post_with_quotes_anywhere.js
generated
vendored
Normal file
11
test/fixtures/javascript/post_with_quotes_anywhere.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fetch('https://localhost:28139', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'A': '\'\'a\'',
|
||||
'B': '"',
|
||||
'Cookie': 'x=1\'; y=2"',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Authorization': 'Basic ' + btoa('ol\':asd"')
|
||||
},
|
||||
body: 'a=b&c="&d=\''
|
||||
});
|
||||
5
test/fixtures/javascript/post_with_urlencoded_data.js
generated
vendored
5
test/fixtures/javascript/post_with_urlencoded_data.js
generated
vendored
@@ -11,5 +11,8 @@ fetch('http://localhost:28139/echo/html/', {
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Connection': 'keep-alive'
|
||||
},
|
||||
body: 'msg1=wow&msg2=such'
|
||||
body: new URLSearchParams({
|
||||
'msg1': 'wow',
|
||||
'msg2': 'such'
|
||||
})
|
||||
});
|
||||
|
||||
24
test/fixtures/javascript/post_with_urlencoded_data_and_headers.js
generated
vendored
24
test/fixtures/javascript/post_with_urlencoded_data_and_headers.js
generated
vendored
@@ -10,5 +10,27 @@ fetch('http://localhost:28139/api/Listing.svc/PropertySearch_Post', {
|
||||
'Referer': 'http://www.realtor.ca/Residential/Map.aspx',
|
||||
'Connection': 'keep-alive'
|
||||
},
|
||||
body: 'CultureId=1&ApplicationId=1&RecordsPerPage=200&MaximumResults=200&PropertyTypeId=300&TransactionTypeId=2&StoreyRange=0-0&BuildingTypeId=1&BedRange=0-0&BathRange=0-0&LongitudeMin=-79.3676805496215&LongitudeMax=-79.27300930023185&LatitudeMin=43.660358732823845&LatitudeMax=43.692390574029936&SortOrder=A&SortBy=1&viewState=m&Longitude=-79.4107246398925&Latitude=43.6552047278685&ZoomLevel=13&CurrentPage=1'
|
||||
body: new URLSearchParams({
|
||||
'CultureId': '1',
|
||||
'ApplicationId': '1',
|
||||
'RecordsPerPage': '200',
|
||||
'MaximumResults': '200',
|
||||
'PropertyTypeId': '300',
|
||||
'TransactionTypeId': '2',
|
||||
'StoreyRange': '0-0',
|
||||
'BuildingTypeId': '1',
|
||||
'BedRange': '0-0',
|
||||
'BathRange': '0-0',
|
||||
'LongitudeMin': '-79.3676805496215',
|
||||
'LongitudeMax': '-79.27300930023185',
|
||||
'LatitudeMin': '43.660358732823845',
|
||||
'LatitudeMax': '43.692390574029936',
|
||||
'SortOrder': 'A',
|
||||
'SortBy': '1',
|
||||
'viewState': 'm',
|
||||
'Longitude': '-79.4107246398925',
|
||||
'Latitude': '43.6552047278685',
|
||||
'ZoomLevel': '13',
|
||||
'CurrentPage': '1'
|
||||
})
|
||||
});
|
||||
|
||||
7
test/fixtures/javascript/post_xpost.js
generated
vendored
Normal file
7
test/fixtures/javascript/post_xpost.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
fetch('http://localhost:28139/api/xxxxxxxxxxxxxxxx', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: '{"keywords":"php","page":1,"searchMode":1}'
|
||||
});
|
||||
2
test/fixtures/javascript/put_basic_auth_json_data.js
generated
vendored
2
test/fixtures/javascript/put_basic_auth_json_data.js
generated
vendored
@@ -4,5 +4,5 @@ fetch('http://localhost:28139/test/_security', {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Authorization': 'Basic ' + btoa('admin:123')
|
||||
},
|
||||
body: JSON.stringify({"admins":{"names":[], "roles":[]}, "readers":{"names":["joe"],"roles":[]}})
|
||||
body: '{"admins":{"names":[], "roles":[]}, "readers":{"names":["joe"],"roles":[]}}'
|
||||
});
|
||||
|
||||
14
test/fixtures/javascript/put_with_T_option.js
generated
vendored
Normal file
14
test/fixtures/javascript/put_with_T_option.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
fetch('http://localhost:28139/twitter/_mapping/user?pretty', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
// body: '{"properties": {"email": {"type": "keyword"}}}',
|
||||
body: JSON.stringify({
|
||||
'properties': {
|
||||
'email': {
|
||||
'type': 'keyword'
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
14
test/fixtures/javascript/put_xput.js
generated
vendored
Normal file
14
test/fixtures/javascript/put_xput.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
fetch('http://localhost:28139/twitter/_mapping/user?pretty', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
// body: '{"properties": {"email": {"type": "keyword"}}}',
|
||||
body: JSON.stringify({
|
||||
'properties': {
|
||||
'email': {
|
||||
'type': 'keyword'
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
2
test/fixtures/javascript/strange_http_method.js
generated
vendored
2
test/fixtures/javascript/strange_http_method.js
generated
vendored
@@ -1,3 +1,3 @@
|
||||
fetch('localhost:28139', {
|
||||
method: 'WHAT'
|
||||
method: 'wHat'
|
||||
});
|
||||
|
||||
4
test/fixtures/javascript/upload_file.js
generated
vendored
Normal file
4
test/fixtures/javascript/upload_file.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
fetch('http://localhost:28139/file.txt', {
|
||||
method: 'PUT',
|
||||
body: File(['<data goes here>'], 'file.txt')
|
||||
});
|
||||
6
test/fixtures/node/get_proxy.js
generated
vendored
Normal file
6
test/fixtures/node/get_proxy.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import fetch from 'node-fetch';
|
||||
import HttpsProxyAgent from 'https-proxy-agent';
|
||||
|
||||
fetch('http://localhost:28139', {
|
||||
agent: new HttpsProxyAgent('http://localhost:8080')
|
||||
});
|
||||
8
test/fixtures/node/get_user_agent.js
generated
vendored
Normal file
8
test/fixtures/node/get_user_agent.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/vc/moviesmagic?p=5&pub=testmovie&tkn=817263812', {
|
||||
headers: {
|
||||
'x-msisdn': 'XXXXXXXXXXXXX',
|
||||
'user-agent': 'Mozilla Android6.1'
|
||||
}
|
||||
});
|
||||
13
test/fixtures/node/get_with_browser_headers.js
generated
vendored
Normal file
13
test/fixtures/node/get_with_browser_headers.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/', {
|
||||
headers: {
|
||||
'Accept-Encoding': 'gzip, deflate, sdch',
|
||||
'Accept-Language': 'en-US,en;q=0.8',
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
|
||||
'Referer': 'http://www.wikipedia.org/',
|
||||
'Cookie': 'GeoIP=US:Albuquerque:35.1241:-106.7675:v4; uls-previous-languages=%5B%22en%22%5D; mediaWiki.user.sessionId=VaHaeVW3m0ymvx9kacwshZIDkv8zgF9y; centralnotice_buckets_by_campaign=%7B%22C14_enUS_dsk_lw_FR%22%3A%7B%22val%22%3A%220%22%2C%22start%22%3A1412172000%2C%22end%22%3A1422576000%7D%2C%22C14_en5C_dec_dsk_FR%22%3A%7B%22val%22%3A3%2C%22start%22%3A1417514400%2C%22end%22%3A1425290400%7D%2C%22C14_en5C_bkup_dsk_FR%22%3A%7B%22val%22%3A1%2C%22start%22%3A1417428000%2C%22end%22%3A1425290400%7D%7D; centralnotice_bannercount_fr12=22; centralnotice_bannercount_fr12-wait=14',
|
||||
'Connection': 'keep-alive'
|
||||
}
|
||||
});
|
||||
15
test/fixtures/node/get_with_form.js
generated
vendored
Normal file
15
test/fixtures/node/get_with_form.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import fetch, { FormData } from 'node-fetch';
|
||||
|
||||
const form = new FormData();
|
||||
form.append('from', 'test@tester.com');
|
||||
form.append('to', 'devs@tester.net');
|
||||
form.append('subject', 'Hello');
|
||||
form.append('text', 'Testing the converter!');
|
||||
|
||||
fetch('http://localhost:28139/v3', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Basic ' + btoa('test:')
|
||||
},
|
||||
body: form
|
||||
});
|
||||
8
test/fixtures/node/get_with_header_without_value.js
generated
vendored
Normal file
8
test/fixtures/node/get_with_header_without_value.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('localhost:28139/get', {
|
||||
headers: {
|
||||
'Content-Type': 'text/xml;charset=UTF-8',
|
||||
'getWorkOrderCancel': ''
|
||||
}
|
||||
});
|
||||
7
test/fixtures/node/get_with_single_header.js
generated
vendored
Normal file
7
test/fixtures/node/get_with_single_header.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/', {
|
||||
headers: {
|
||||
'foo': 'bar'
|
||||
}
|
||||
});
|
||||
5
test/fixtures/node/head.js
generated
vendored
Normal file
5
test/fixtures/node/head.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/page', {
|
||||
method: 'HEAD'
|
||||
});
|
||||
10
test/fixtures/node/j_data_priority_than_f.js
generated
vendored
Normal file
10
test/fixtures/node/j_data_priority_than_f.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/post', {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams({
|
||||
'data1': 'data1',
|
||||
'data2': 'data2',
|
||||
'data3': 'data3'
|
||||
})
|
||||
});
|
||||
9
test/fixtures/node/j_patch_array.js
generated
vendored
Normal file
9
test/fixtures/node/j_patch_array.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/patch', {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: 'item[]=1&item[]=2&item[]=3'
|
||||
});
|
||||
9
test/fixtures/node/j_patch_file_only.js
generated
vendored
Normal file
9
test/fixtures/node/j_patch_file_only.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import fetch, { FormData, fileFromSync } from 'node-fetch';
|
||||
|
||||
const form = new FormData();
|
||||
form.append('file1', fileFromSync('./fixtures/curl_commands/delete.sh'));
|
||||
|
||||
fetch('http://localhost:28139/patch', {
|
||||
method: 'PATCH',
|
||||
body: form
|
||||
});
|
||||
11
test/fixtures/node/j_patch_file_with_data.js
generated
vendored
Normal file
11
test/fixtures/node/j_patch_file_with_data.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import fetch, { FormData, fileFromSync } from 'node-fetch';
|
||||
|
||||
const form = new FormData();
|
||||
form.append('file1', fileFromSync('./fixtures/curl_commands/delete.sh'));
|
||||
form.append('form1', 'form+data+1');
|
||||
form.append('form2', 'form_data_2');
|
||||
|
||||
fetch('http://localhost:28139/patch', {
|
||||
method: 'PATCH',
|
||||
body: form
|
||||
});
|
||||
10
test/fixtures/node/j_post_data_wo_verb.js
generated
vendored
Normal file
10
test/fixtures/node/j_post_data_wo_verb.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/post', {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams({
|
||||
'data1': 'data1',
|
||||
'data2': 'data2',
|
||||
'data3': 'data3'
|
||||
})
|
||||
});
|
||||
10
test/fixtures/node/j_post_form_f.js
generated
vendored
Normal file
10
test/fixtures/node/j_post_form_f.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import fetch, { FormData } from 'node-fetch';
|
||||
|
||||
const form = new FormData();
|
||||
form.append('d1', 'data1');
|
||||
form.append('d2', 'data');
|
||||
|
||||
fetch('http://localhost:28139/post', {
|
||||
method: 'POST',
|
||||
body: form
|
||||
});
|
||||
11
test/fixtures/node/multiline_post_with_data.js
generated
vendored
Normal file
11
test/fixtures/node/multiline_post_with_data.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/echo/html/', {
|
||||
headers: {
|
||||
'Origin': 'http://fiddle.jshell.net'
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
'msg1': 'value1',
|
||||
'msg2': 'value2'
|
||||
})
|
||||
});
|
||||
13
test/fixtures/node/multipart_post.js
generated
vendored
Normal file
13
test/fixtures/node/multipart_post.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import fetch, { FormData, fileFromSync } from 'node-fetch';
|
||||
|
||||
const form = new FormData();
|
||||
form.append('attributes', '{"name":"tigers.jpeg", "parent":{"id":"11446498"}}');
|
||||
form.append('file', fileFromSync('myfile.jpg'));
|
||||
|
||||
fetch('https://localhost:28139/api/2.0/files/content', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Bearer ACCESS_TOKEN'
|
||||
},
|
||||
body: form
|
||||
});
|
||||
14
test/fixtures/node/multipart_with_headers.js
generated
vendored
Normal file
14
test/fixtures/node/multipart_with_headers.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import fetch, { FormData, fileFromSync } from 'node-fetch';
|
||||
|
||||
const form = new FormData();
|
||||
form.append('attributes', '{"name":"tigers.jpeg", "parent":{"id":"11446498"}}');
|
||||
form.append('file', fileFromSync('myfile.jpg'));
|
||||
|
||||
fetch('https://localhost:28139/api/2.0/files/content', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Bearer ACCESS_TOKEN',
|
||||
'X-Nice': 'Header'
|
||||
},
|
||||
body: form
|
||||
});
|
||||
9
test/fixtures/node/multiple_d_post.js
generated
vendored
Normal file
9
test/fixtures/node/multiple_d_post.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('https://localhost:28139/webservices/rest.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: 'version=1.2&auth_user=fdgxf&auth_pwd=oxfdscds&json_data={ "operation": "core/get", "class": "Software", "key": "key" }'
|
||||
});
|
||||
19
test/fixtures/node/options.js
generated
vendored
Normal file
19
test/fixtures/node/options.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('https://localhost:28139/api/tunein/queue-and-play?deviceSerialNumber=xxx^&deviceType=xxx^&guideId=s56876^&contentType=station^&callSign=^&mediaOwnerCustomerId=xxx', {
|
||||
method: 'OPTIONS',
|
||||
headers: {
|
||||
'Pragma': 'no-cache',
|
||||
'Access-Control-Request-Method': 'POST',
|
||||
'Origin': 'https://alexa.amazon.de',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Language': 'de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',
|
||||
'Accept': '*/*',
|
||||
'Cache-Control': 'no-cache',
|
||||
'Referer': 'https://alexa.amazon.de/spa/index.html',
|
||||
'Connection': 'keep-alive',
|
||||
'DNT': '1',
|
||||
'Access-Control-Request-Headers': 'content-type,csrf'
|
||||
}
|
||||
});
|
||||
22
test/fixtures/node/patch.js
generated
vendored
Normal file
22
test/fixtures/node/patch.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/go/api/agents/adb9540a-b954-4571-9d9b-2f330739d4da', {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Accept': 'application/vnd.go.cd.v4+json',
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Basic ' + btoa('username:password')
|
||||
},
|
||||
// body: '{\n "hostname": "agent02.example.com",\n "agent_config_state": "Enabled",\n "resources": ["Java","Linux"],\n "environments": ["Dev"]\n }',
|
||||
body: JSON.stringify({
|
||||
'hostname': 'agent02.example.com',
|
||||
'agent_config_state': 'Enabled',
|
||||
'resources': [
|
||||
'Java',
|
||||
'Linux'
|
||||
],
|
||||
'environments': [
|
||||
'Dev'
|
||||
]
|
||||
})
|
||||
});
|
||||
11
test/fixtures/node/post_basic_auth_url_encoded_data.js
generated
vendored
Normal file
11
test/fixtures/node/post_basic_auth_url_encoded_data.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/api/oauth/token/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Basic ' + btoa('foo:bar')
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
'grant_type': 'client_credentials'
|
||||
})
|
||||
});
|
||||
77
test/fixtures/node/post_data_binary_with_equals.js
generated
vendored
Normal file
77
test/fixtures/node/post_data_binary_with_equals.js
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/api/service.svc?action=CreateItem&ID=-37&AC=1', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Cookie': 'X-BackEndCookie=S-1-5-21-1234556-56678-12345-2345=alphanumericstring12345/anotheralphanumericstring12345/scsiAdf/P; ClientId=LoremIupsum; PrivateComputer=true; PBack=0; cadata=bx88rrCBehITlBWSozO2l2hlFGu//JjT1/k6dewX5shV32jANUZSMU6GR+M25B6YpBODEgXzxfIHDnvxNC6SJoaE/d8RWX3uDnbkd+m91jNhMXNSYIRYTJHVFdPG06AE; cadataTTL=NfDhBViTJMUdC+ir+6BYvg==; cadataKey=qUY+OLTD9V14CFK6/CUPyrJWMxl1FFqZFjB8/qcS0/q55eqGvP9bWvX+XuSYVv3hIGAn9QNPhIDK6NP9LwCBdu25f2BUFDUWJruGO8MW02izSWzRUnni00xWQq3Y3nNKvpvO+OIR641BPHVZ0+lzCw2Wt8uzEnryCWAjlleozF/XWjpTN4/AaTmcIjEZUDN+fo4494rD0mADtEHv2gmd5mhLe+iyii/L9nAB3UuiJomwbRbKgy22Tj8cyavmLC4ZaViqW9E102NOLU4FYLgdZVET+mbdg==; cadataIV=bTM88YL1zmz7FsBEB0y3nI2SrdSTy+KLxCpx2FRfIZYFo2spN1IHQMSCT76OXrg79sVPhyqXk+N9rOj6M9KsQl4KqMNVBcoXgp24POpgoTwd4FBmKtAYbd9SDErna3jrMO168ML9PDG18K3CnBf6YG1tsIs0gXOEP9LzHVmUPF7KCKqUFiOiZGWuwmPhl85eo77BbEpVN2JkPnzuQWn6tC0cY4f2cJDlr3Z23SrAUVwwXmgRg2DXfOF5MIEkpwYiiI6sABCD9rsSnE6zTXlvZg33hjiD/ywUV1ZWjI2M/4zBixa4s150+dOnMmvtEFs/nOMnvMJui4PEDlTA==; cadataSig=WL3hB+av7sO3bzjL+Efe5b4exnvQxSInH3U5jDvfnPcttSp0XUF3y/NB573C0CTBYuOH/40smFssXlrKhT9tG2ITivdSIIamOmarmC8XwFOv9qQIFMHofcO/jjRDMqF0qRk7WBAC2FgBQrf2Tvq7wk5IX/JHn6zhlgKALAAqH9L9JNC244etnjj9YNaMDYEHV2M2jVTu3FsELqw1rSSqp0hEBlh+aFBvYCBg5hS1mVI76ZCHZVa0OUejiH2yiZyJIKHUI+Sv0rpU3iiQNtIFmGEdwhoo/rga4s4Dc2UsJLQ8c0yGlZgflYs+7Q5gPr74/mTUin60ej/w3M0roUl3FQ==; UC=d8be544621964f3c9865b3ee872fd432; AppcacheVer=15.0.1236.3:en-usbase; X-OWA-CANARY=VOXQP6xtGkiNnv7E4rFt8TrmclqVFtQI4IJqZflrR7Wz9AMPkMsFoyAlquw1YGsTUxIkVouAcvk.',
|
||||
'Origin': 'https://nih.mail.edu.fr',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'X-EWS-TargetVersion': '2.5',
|
||||
'Accept-Language': 'en-US,en;q=0.8',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
|
||||
'Action': 'CreateItem',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Connection': 'keep-alive',
|
||||
'X-OWA-CANARY': 'VOXQP6xtGkiNnv7E4rFt8TrmclqVFtQI4IJqZflrR7Wz9AMPkMsFoyAlquw1YGsTUxIkVouAcvk.',
|
||||
'X-OWA-ActionName': 'CreateMessageForComposeSend',
|
||||
'X-OWA-ActionId': '-37',
|
||||
'X-OWA-ServiceUnavailableOnTransientError': 'true',
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Accept': '*/*',
|
||||
'Referer': 'https://localhost/api/',
|
||||
'X-OWA-ClientBuildVersion': '15.0.1236.3',
|
||||
'X-OWA-CorrelationId': '2f11f8fb-f6c6-43a5-881d-8a1b242a4e70_148023102251337',
|
||||
'DNT': '1',
|
||||
'X-OWA-ClientBegin': '2016-11-27T07:17:02.513',
|
||||
'X-OWA-Attempt': '1'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
'__type': 'CreateItemJsonRequest:#Exchange',
|
||||
'Header': {
|
||||
'__type': 'JsonRequestHeaders:#Exchange',
|
||||
'RequestServerVersion': 'Exchange2013',
|
||||
'TimeZoneContext': {
|
||||
'__type': 'TimeZoneContext:#Exchange',
|
||||
'TimeZoneDefinition': {
|
||||
'__type': 'TimeZoneDefinitionType:#Exchange',
|
||||
'Id': 'France Standard Time'
|
||||
}
|
||||
}
|
||||
},
|
||||
'Body': {
|
||||
'__type': 'CreateItemRequest:#Exchange',
|
||||
'Items': [
|
||||
{
|
||||
'__type': 'Message:#Exchange',
|
||||
'Subject': 'API',
|
||||
'Body': {
|
||||
'__type': 'BodyContentType:#Exchange',
|
||||
'BodyType': 'HTML',
|
||||
'Value': '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style></head><body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;"><p>API Test for NickC<br></p></body></html>'
|
||||
},
|
||||
'Importance': 'Normal',
|
||||
'From': null,
|
||||
'ToRecipients': [
|
||||
{
|
||||
'Name': 'George LUCAS',
|
||||
'EmailAddress': 'George.LUCAS@nih.mail.edu.fr',
|
||||
'RoutingType': 'SMTP',
|
||||
'MailboxType': 'Mailbox',
|
||||
'OriginalDisplayName': 'George.LUCAS@nih.mail.edu.fr',
|
||||
'SipUri': ' '
|
||||
}
|
||||
],
|
||||
'CcRecipients': [],
|
||||
'BccRecipients': [],
|
||||
'Sensitivity': 'Normal',
|
||||
'IsDeliveryReceiptRequested': false,
|
||||
'IsReadReceiptRequested': false
|
||||
}
|
||||
],
|
||||
'ClientSupportsIrm': true,
|
||||
'OutboundCharset': 'AutoDetect',
|
||||
'MessageDisposition': 'SendAndSaveCopy',
|
||||
'ComposeOperation': 'newMail'
|
||||
}
|
||||
})
|
||||
});
|
||||
2
test/fixtures/node/post_empty.js
generated
vendored
2
test/fixtures/node/post_empty.js
generated
vendored
@@ -1,4 +1,4 @@
|
||||
var fetch = require('node-fetch');
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139', {
|
||||
method: 'POST',
|
||||
|
||||
9
test/fixtures/node/post_escaped_double_quotes_in_single_quotes.js
generated
vendored
Normal file
9
test/fixtures/node/post_escaped_double_quotes_in_single_quotes.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: 'foo=\\"bar\\"'
|
||||
});
|
||||
9
test/fixtures/node/post_escaped_single_quotes_in_double_quotes.js
generated
vendored
Normal file
9
test/fixtures/node/post_escaped_single_quotes_in_double_quotes.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: 'foo=\\\'bar\\\''
|
||||
});
|
||||
10
test/fixtures/node/post_form.js
generated
vendored
Normal file
10
test/fixtures/node/post_form.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import fetch, { FormData } from 'node-fetch';
|
||||
|
||||
const form = new FormData();
|
||||
form.append('username', 'davidwalsh');
|
||||
form.append('password', 'something');
|
||||
|
||||
fetch('http://localhost:28139/post-to-me.php', {
|
||||
method: 'POST',
|
||||
body: form
|
||||
});
|
||||
9
test/fixtures/node/post_image.js
generated
vendored
Normal file
9
test/fixtures/node/post_image.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import fetch, { FormData, fileFromSync } from 'node-fetch';
|
||||
|
||||
const form = new FormData();
|
||||
form.append('image', fileFromSync('image.jpg'));
|
||||
|
||||
fetch('http://localhost:28139/targetservice', {
|
||||
method: 'POST',
|
||||
body: form
|
||||
});
|
||||
13
test/fixtures/node/post_json.js
generated
vendored
Normal file
13
test/fixtures/node/post_json.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('https://localhost:28139', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
// body: '{ "drink": "coffe" }',
|
||||
body: JSON.stringify({
|
||||
'drink': 'coffe'
|
||||
})
|
||||
});
|
||||
15
test/fixtures/node/post_json_multiple_headers.js
generated
vendored
Normal file
15
test/fixtures/node/post_json_multiple_headers.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('https://localhost:28139/rest/login-sessions', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-API-Version': '200'
|
||||
},
|
||||
// body: '{"userName":"username123","password":"password123", "authLoginDomain":"local"}',
|
||||
body: JSON.stringify({
|
||||
'userName': 'username123',
|
||||
'password': 'password123',
|
||||
'authLoginDomain': 'local'
|
||||
})
|
||||
});
|
||||
9
test/fixtures/node/post_number.js
generated
vendored
Normal file
9
test/fixtures/node/post_number.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: '123'
|
||||
});
|
||||
8
test/fixtures/node/post_quotes_inside_data.js
generated
vendored
Normal file
8
test/fixtures/node/post_quotes_inside_data.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('localhost:28139', {
|
||||
method: 'POST',
|
||||
body: new URLSearchParams({
|
||||
'field': 'don\'t you like quotes'
|
||||
})
|
||||
});
|
||||
9
test/fixtures/node/post_same_field_multiple_times.js
generated
vendored
Normal file
9
test/fixtures/node/post_same_field_multiple_times.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: 'foo=bar&foo=&foo=barbar'
|
||||
});
|
||||
16
test/fixtures/node/post_with_browser_headers.js
generated
vendored
Normal file
16
test/fixtures/node/post_with_browser_headers.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/ajax/demo_post.asp', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Origin': 'http://www.w3schools.com',
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept-Language': 'en-US,en;q=0.8',
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
|
||||
'Accept': '*/*',
|
||||
'Referer': 'http://www.w3schools.com/ajax/tryit_view.asp?x=0.07944501144811511',
|
||||
'Cookie': '_gat=1; ASPSESSIONIDACCRDTDC=MCMDKFMBLLLHGKCGNMKNGPKI; _ga=GA1.2.1424920226.1419478126',
|
||||
'Connection': 'keep-alive',
|
||||
'Content-Length': '0'
|
||||
}
|
||||
});
|
||||
9
test/fixtures/node/post_with_colon_in_header.js
generated
vendored
Normal file
9
test/fixtures/node/post_with_colon_in_header.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/endpoint', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'key': 'abcdefg'
|
||||
}
|
||||
});
|
||||
20
test/fixtures/node/post_with_data-ascii.js
generated
vendored
Normal file
20
test/fixtures/node/post_with_data-ascii.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/echo/html/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Origin': 'http://fiddle.jshell.net',
|
||||
'Accept-Encoding': 'gzip, deflate',
|
||||
'Accept-Language': 'en-US,en;q=0.8',
|
||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Accept': '*/*',
|
||||
'Referer': 'http://fiddle.jshell.net/_display/',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Connection': 'keep-alive'
|
||||
},
|
||||
body: new URLSearchParams({
|
||||
'msg1': 'wow',
|
||||
'msg2': 'such'
|
||||
})
|
||||
});
|
||||
9
test/fixtures/node/post_with_data_binary.js
generated
vendored
Normal file
9
test/fixtures/node/post_with_data_binary.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
fetch('http://localhost:28139/post', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
body: '{"title":"china1"}'
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user