mirror of
https://github.com/curlconverter/curlconverter.git
synced 2022-05-22 02:35:29 +03:00
axios.post .put and .patch expect data as the second argument (#393)
* axios.post .put .patch take data as the 2nd arg * rename formData to form * add warning about data not being sent * sort imports properly * passing an object as data sends it as json, not urlencoded
This commit is contained in:
committed by
GitHub
parent
2d9ff6f0aa
commit
dda866a741
@@ -42,25 +42,34 @@ const repr = (value: string | object, indentLevel?: number): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO: @
|
// TODO: @
|
||||||
const getDataString = (request: Request): string | null => {
|
const _getDataString = (request: Request): [string | null, string | null] => {
|
||||||
if (!request.data) {
|
if (!request.data) {
|
||||||
return null;
|
return [null, null];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const originalStringRepr = repr(request.data);
|
||||||
|
|
||||||
const contentType = util.getContentType(request);
|
const contentType = util.getContentType(request);
|
||||||
|
// can have things like ; charset=utf-8 which we want to preserve
|
||||||
|
const exactContentType = util.getHeader(request, "content-type");
|
||||||
if (contentType === "application/json") {
|
if (contentType === "application/json") {
|
||||||
const originalStringRepr = repr(request.data);
|
|
||||||
|
|
||||||
const parsed = JSON.parse(request.data);
|
const parsed = JSON.parse(request.data);
|
||||||
const backToString = JSON.stringify(parsed);
|
// Only arrays and {} can be passed to axios to be encoded as JSON
|
||||||
const jsonAsJavaScriptString = repr(parsed, 1);
|
// TODO: check this in other generators
|
||||||
|
if (typeof parsed !== "object" || parsed === null) {
|
||||||
let result = "";
|
return [originalStringRepr, null];
|
||||||
if (request.data !== backToString) {
|
|
||||||
result += " // data: " + originalStringRepr + ",\n";
|
|
||||||
}
|
}
|
||||||
result += " data: JSON.stringify(" + jsonAsJavaScriptString + "),\n";
|
const roundtrips = JSON.stringify(parsed) === request.data;
|
||||||
return result;
|
const jsonAsJavaScript = repr(parsed, 1);
|
||||||
|
if (
|
||||||
|
roundtrips &&
|
||||||
|
exactContentType === "application/json" &&
|
||||||
|
util.getHeader(request, "accept") === "application/json, text/plain, */*"
|
||||||
|
) {
|
||||||
|
util.deleteHeader(request, "content-type");
|
||||||
|
util.deleteHeader(request, "accept");
|
||||||
|
}
|
||||||
|
return [jsonAsJavaScript, roundtrips ? null : originalStringRepr];
|
||||||
}
|
}
|
||||||
if (contentType === "application/x-www-form-urlencoded") {
|
if (contentType === "application/x-www-form-urlencoded") {
|
||||||
const query = util.parseQueryString(request.data);
|
const query = util.parseQueryString(request.data);
|
||||||
@@ -69,10 +78,165 @@ const getDataString = (request: Request): string | null => {
|
|||||||
queryDict &&
|
queryDict &&
|
||||||
Object.values(queryDict).every((v) => typeof v === "string")
|
Object.values(queryDict).every((v) => typeof v === "string")
|
||||||
) {
|
) {
|
||||||
return " data: " + repr(queryDict, 1) + ",\n";
|
// Technically axios sends
|
||||||
|
// application/x-www-form-urlencoded;charset=utf-8
|
||||||
|
if (exactContentType === "application/x-www-form-urlencoded") {
|
||||||
|
util.deleteHeader(request, "content-type");
|
||||||
|
}
|
||||||
|
// TODO: check roundtrip, add a comment
|
||||||
|
return ["new URLSearchParams(" + repr(queryDict, 1) + ")", null];
|
||||||
|
} else {
|
||||||
|
return [originalStringRepr, null];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return [null, null];
|
||||||
|
};
|
||||||
|
const getDataString = (request: Request): [string | null, string | null] => {
|
||||||
|
if (!request.data) {
|
||||||
|
return [null, null];
|
||||||
|
}
|
||||||
|
|
||||||
|
let dataString = null;
|
||||||
|
let commentedOutDataString = null;
|
||||||
|
try {
|
||||||
|
[dataString, commentedOutDataString] = _getDataString(request);
|
||||||
|
} catch {}
|
||||||
|
if (!dataString) {
|
||||||
|
dataString = repr(request.data);
|
||||||
|
}
|
||||||
|
return [dataString, commentedOutDataString];
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildConfigObject = (
|
||||||
|
request: Request,
|
||||||
|
method: string,
|
||||||
|
methods: string[],
|
||||||
|
dataMethods: string[],
|
||||||
|
hasSearchParams: boolean,
|
||||||
|
warnings: Warnings
|
||||||
|
): string => {
|
||||||
|
let code = "{\n";
|
||||||
|
|
||||||
|
if (!methods.includes(method)) {
|
||||||
|
// Axios uppercases methods
|
||||||
|
code += " method: " + repr(method) + ",\n";
|
||||||
|
}
|
||||||
|
if (hasSearchParams) {
|
||||||
|
// code += " params,\n";
|
||||||
|
code += " params: params,\n";
|
||||||
|
} else if (request.queryDict) {
|
||||||
|
code += " params: " + repr(request.queryDict, 1) + ",\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
const [dataString, commentedOutDataString] = getDataString(request); // can delete headers
|
||||||
|
|
||||||
|
if ((request.headers && request.headers.length) || request.multipartUploads) {
|
||||||
|
code += " headers: {\n";
|
||||||
|
if (request.multipartUploads) {
|
||||||
|
code += " ...form.getHeaders(),\n";
|
||||||
|
}
|
||||||
|
for (const [key, value] of request.headers || []) {
|
||||||
|
code += " " + repr(key) + ": " + repr(value || "") + ",\n";
|
||||||
|
}
|
||||||
|
if (code.endsWith(",\n")) {
|
||||||
|
code = code.slice(0, -2);
|
||||||
|
code += "\n";
|
||||||
|
}
|
||||||
|
code += " },\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.auth) {
|
||||||
|
const [username, password] = request.auth;
|
||||||
|
code += " auth: {\n";
|
||||||
|
code += " username: " + repr(username);
|
||||||
|
if (password) {
|
||||||
|
code += ",\n";
|
||||||
|
code += " password: " + repr(password) + "\n";
|
||||||
|
} else {
|
||||||
|
code += "\n";
|
||||||
|
}
|
||||||
|
code += " },\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dataMethods.includes(method)) {
|
||||||
|
if (request.data) {
|
||||||
|
if (commentedOutDataString) {
|
||||||
|
code += " // data: " + commentedOutDataString + ",\n";
|
||||||
|
}
|
||||||
|
code += " data: " + dataString + ",\n";
|
||||||
|
} 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 (request.timeout) {
|
||||||
|
const timeout = parseFloat(request.timeout);
|
||||||
|
if (!isNaN(timeout) && timeout > 0) {
|
||||||
|
code += " timeout: " + timeout * 1000 + ",\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.proxy === "") {
|
||||||
|
// TODO: this probably won't be set if it's empty
|
||||||
|
// TODO: could have --socks5 proxy
|
||||||
|
code += " proxy: false,\n";
|
||||||
|
} else if (request.proxy) {
|
||||||
|
// TODO: do this parsing in utils.ts
|
||||||
|
const proxy = request.proxy.includes("://")
|
||||||
|
? request.proxy
|
||||||
|
: "http://" + request.proxy;
|
||||||
|
let [protocol, host] = proxy.split(/:\/\/(.*)/s, 2);
|
||||||
|
protocol =
|
||||||
|
protocol.toLowerCase() === "socks" ? "socks4" : protocol.toLowerCase();
|
||||||
|
host = host ? host : "";
|
||||||
|
|
||||||
|
let port = "1080";
|
||||||
|
const proxyPart = host.match(/:([0-9]+$)/);
|
||||||
|
if (proxyPart) {
|
||||||
|
host = host.slice(0, proxyPart.index);
|
||||||
|
port = proxyPart[1];
|
||||||
|
}
|
||||||
|
const portInt = parseInt(port);
|
||||||
|
|
||||||
|
code += " proxy: {\n";
|
||||||
|
code += " protocol: " + repr(protocol) + ",\n";
|
||||||
|
code += " host: " + repr(host) + ",\n";
|
||||||
|
if (!isNaN(portInt)) {
|
||||||
|
code += " port: " + port + ",\n";
|
||||||
|
} else {
|
||||||
|
code += " port: " + repr(port) + ",\n";
|
||||||
|
}
|
||||||
|
if (request.proxyAuth) {
|
||||||
|
const [proxyUser, proxyPassword] = request.proxyAuth.split(/:(.*)/s, 2);
|
||||||
|
code += " auth: {\n";
|
||||||
|
code += " user: " + repr(proxyUser);
|
||||||
|
if (proxyPassword !== undefined) {
|
||||||
|
code += ",\n";
|
||||||
|
code += " password: " + repr(proxyPassword) + "\n";
|
||||||
|
} else {
|
||||||
|
code += "\n";
|
||||||
|
}
|
||||||
|
code += " },\n";
|
||||||
|
}
|
||||||
|
if (code.endsWith(",\n")) {
|
||||||
|
code = code.slice(0, -2);
|
||||||
|
code += "\n";
|
||||||
|
}
|
||||||
|
code += " },\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code.endsWith(",\n")) {
|
||||||
|
code = code.slice(0, -2);
|
||||||
|
}
|
||||||
|
code += "\n}";
|
||||||
|
return code;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const _toNodeAxios = (
|
export const _toNodeAxios = (
|
||||||
@@ -86,24 +250,6 @@ export const _toNodeAxios = (
|
|||||||
|
|
||||||
let code = "";
|
let code = "";
|
||||||
|
|
||||||
const needsConfig =
|
|
||||||
request.query ||
|
|
||||||
request.queryDict ||
|
|
||||||
request.headers ||
|
|
||||||
request.auth ||
|
|
||||||
request.data ||
|
|
||||||
request.multipartUploads ||
|
|
||||||
request.timeout ||
|
|
||||||
request.proxy;
|
|
||||||
|
|
||||||
// TODO: need to add http:// to URL?
|
|
||||||
const method = request.method.toLowerCase();
|
|
||||||
if (method === "get" && !needsConfig) {
|
|
||||||
// TODO: is this actually helpful?
|
|
||||||
code = "const response = await axios(" + repr(request.url) + ");\n";
|
|
||||||
return [importCode + "\n" + code, warnings];
|
|
||||||
}
|
|
||||||
|
|
||||||
const hasSearchParams =
|
const hasSearchParams =
|
||||||
request.query &&
|
request.query &&
|
||||||
(!request.queryDict ||
|
(!request.queryDict ||
|
||||||
@@ -119,15 +265,15 @@ export const _toNodeAxios = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (request.multipartUploads) {
|
if (request.multipartUploads) {
|
||||||
imports.add(["form-data", "FormData"]);
|
imports.add(["FormData", "form-data"]);
|
||||||
code += "const formData = new FormData();\n";
|
code += "const form = new FormData();\n";
|
||||||
for (const {
|
for (const {
|
||||||
name,
|
name,
|
||||||
filename,
|
filename,
|
||||||
content,
|
content,
|
||||||
contentFile,
|
contentFile,
|
||||||
} of request.multipartUploads) {
|
} of request.multipartUploads) {
|
||||||
code += "formData.append(" + repr(name) + ", ";
|
code += "form.append(" + repr(name) + ", ";
|
||||||
if (contentFile === "-") {
|
if (contentFile === "-") {
|
||||||
code += "fs.readFileSync(0).toString()";
|
code += "fs.readFileSync(0).toString()";
|
||||||
imports.add(["fs", "fs"]);
|
imports.add(["fs", "fs"]);
|
||||||
@@ -145,125 +291,102 @@ export const _toNodeAxios = (
|
|||||||
code += "\n";
|
code += "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const method = request.method.toLowerCase();
|
||||||
const methods = ["get", "delete", "head", "options", "post", "put", "patch"];
|
const methods = ["get", "delete", "head", "options", "post", "put", "patch"];
|
||||||
const fn = methods.includes(method) ? method : "request";
|
code += "const response = await axios";
|
||||||
code += "const response = await axios." + fn + "(";
|
if (methods.includes(method)) {
|
||||||
|
code += "." + method;
|
||||||
|
}
|
||||||
|
code += "(";
|
||||||
|
|
||||||
code += repr(
|
const url =
|
||||||
request.queryDict || hasSearchParams ? request.urlWithoutQuery : request.url
|
request.queryDict || hasSearchParams
|
||||||
|
? request.urlWithoutQuery
|
||||||
|
: request.url;
|
||||||
|
|
||||||
|
// axios only supports posting data with these HTTP methods
|
||||||
|
// You can also post data with OPTIONS, but that has to go in the config object
|
||||||
|
const dataMethods = ["post", "put", "patch"];
|
||||||
|
let needsConfig = !!(
|
||||||
|
request.query ||
|
||||||
|
request.queryDict ||
|
||||||
|
request.headers ||
|
||||||
|
request.auth ||
|
||||||
|
request.multipartUploads ||
|
||||||
|
(request.data && !dataMethods.includes(method)) ||
|
||||||
|
request.timeout ||
|
||||||
|
request.proxy
|
||||||
);
|
);
|
||||||
|
const needsData =
|
||||||
|
dataMethods.includes(method) &&
|
||||||
|
(request.data || request.multipartUploads || needsConfig);
|
||||||
|
|
||||||
if (fn === "request" || needsConfig) {
|
let dataString, commentedOutDataString;
|
||||||
code += ", {\n";
|
if (needsData) {
|
||||||
if (fn === "request") {
|
code += "\n";
|
||||||
// Axios probably uppercases methods
|
code += " " + repr(url) + ",\n";
|
||||||
code += " method: " + repr(request.method.toLowerCase()) + ",\n";
|
|
||||||
}
|
|
||||||
if (hasSearchParams) {
|
|
||||||
// code += " params,\n";
|
|
||||||
code += " params: params,\n";
|
|
||||||
} else if (request.queryDict) {
|
|
||||||
code += " params: " + repr(request.queryDict, 1) + ",\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.headers) {
|
|
||||||
code +=
|
|
||||||
" headers: " + repr(Object.fromEntries(request.headers), 1) + ",\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.auth) {
|
|
||||||
const [username, password] = request.auth;
|
|
||||||
code += " auth: {\n";
|
|
||||||
code += " username: " + repr(username);
|
|
||||||
if (password) {
|
|
||||||
code += ",\n";
|
|
||||||
code += " password: " + repr(password) + "\n";
|
|
||||||
} else {
|
|
||||||
code += "\n";
|
|
||||||
}
|
|
||||||
code += " },\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.data) {
|
if (request.data) {
|
||||||
try {
|
try {
|
||||||
const dataString = getDataString(request);
|
[dataString, commentedOutDataString] = getDataString(request);
|
||||||
if (dataString) {
|
if (!dataString) {
|
||||||
code += dataString;
|
dataString = repr(request.data);
|
||||||
} else {
|
|
||||||
code += " data: " + repr(request.data) + ",\n";
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
code += " data: " + repr(request.data) + ",\n";
|
dataString = repr(request.data);
|
||||||
}
|
}
|
||||||
|
if (commentedOutDataString) {
|
||||||
|
code += " // " + commentedOutDataString + ",\n";
|
||||||
|
}
|
||||||
|
code += " " + dataString;
|
||||||
} else if (request.multipartUploads) {
|
} else if (request.multipartUploads) {
|
||||||
code += " data: formData,\n";
|
code += " form";
|
||||||
|
} else if (needsConfig) {
|
||||||
|
// TODO: this works but maybe undefined would be more correct?
|
||||||
|
code += " ''";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
code += repr(url);
|
||||||
|
}
|
||||||
|
|
||||||
if (request.timeout) {
|
// getDataString() can delete a header, so we can end up with an empty config
|
||||||
const timeout = parseFloat(request.timeout);
|
needsConfig = !!(
|
||||||
if (!isNaN(timeout) && timeout > 0) {
|
request.query ||
|
||||||
code += " timeout: " + timeout * 1000 + ",\n";
|
request.queryDict ||
|
||||||
|
(request.headers && request.headers.length) ||
|
||||||
|
request.auth ||
|
||||||
|
request.multipartUploads ||
|
||||||
|
(request.data && !dataMethods.includes(method)) ||
|
||||||
|
request.timeout ||
|
||||||
|
request.proxy
|
||||||
|
);
|
||||||
|
|
||||||
|
if (needsConfig) {
|
||||||
|
const config = buildConfigObject(
|
||||||
|
request,
|
||||||
|
method,
|
||||||
|
methods,
|
||||||
|
dataMethods,
|
||||||
|
!!hasSearchParams,
|
||||||
|
warnings
|
||||||
|
);
|
||||||
|
if (needsData) {
|
||||||
|
code += ",\n";
|
||||||
|
for (const line of config.split("\n")) {
|
||||||
|
code += " " + line + "\n";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
code += ", ";
|
||||||
|
code += config;
|
||||||
}
|
}
|
||||||
|
} else if (needsData) {
|
||||||
if (request.proxy === "") {
|
code += "\n";
|
||||||
// TODO: this probably won't be set if it's empty
|
|
||||||
// TODO: could have --socks5 proxy
|
|
||||||
code += " proxy: false,\n";
|
|
||||||
} else if (request.proxy) {
|
|
||||||
// TODO: do this parsing in utils.ts
|
|
||||||
const proxy = request.proxy.includes("://")
|
|
||||||
? request.proxy
|
|
||||||
: "http://" + request.proxy;
|
|
||||||
let [protocol, host] = proxy.split(/:\/\/(.*)/s, 2);
|
|
||||||
protocol =
|
|
||||||
protocol.toLowerCase() === "socks" ? "socks4" : protocol.toLowerCase();
|
|
||||||
host = host ? host : "";
|
|
||||||
|
|
||||||
let port = "1080";
|
|
||||||
const proxyPart = host.match(/:([0-9]+$)/);
|
|
||||||
if (proxyPart) {
|
|
||||||
host = host.slice(0, proxyPart.index);
|
|
||||||
port = proxyPart[1];
|
|
||||||
}
|
|
||||||
const portInt = parseInt(port);
|
|
||||||
|
|
||||||
code += " proxy: {\n";
|
|
||||||
code += " protocol: " + repr(protocol) + ",\n";
|
|
||||||
code += " host: " + repr(host) + ",\n";
|
|
||||||
if (!isNaN(portInt)) {
|
|
||||||
code += " port: " + port + ",\n";
|
|
||||||
} else {
|
|
||||||
code += " port: " + repr(port) + ",\n";
|
|
||||||
}
|
|
||||||
if (request.proxyAuth) {
|
|
||||||
const [proxyUser, proxyPassword] = request.proxyAuth.split(/:(.*)/s, 2);
|
|
||||||
code += " auth: {\n";
|
|
||||||
code += " user: " + repr(proxyUser);
|
|
||||||
if (proxyPassword !== undefined) {
|
|
||||||
code += ",\n";
|
|
||||||
code += " password: " + repr(proxyPassword) + "\n";
|
|
||||||
} else {
|
|
||||||
code += "\n";
|
|
||||||
}
|
|
||||||
code += " },\n";
|
|
||||||
}
|
|
||||||
if (code.endsWith(",\n")) {
|
|
||||||
code = code.slice(0, -2);
|
|
||||||
code += "\n";
|
|
||||||
}
|
|
||||||
code += " },\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (code.endsWith(",\n")) {
|
|
||||||
code = code.slice(0, -2);
|
|
||||||
}
|
|
||||||
code += "\n}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code += ");\n";
|
code += ");\n";
|
||||||
|
|
||||||
for (const [imp, varName] of Array.from(imports).sort()) {
|
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";
|
importCode += "const " + varName + " = require(" + repr(imp) + ");\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
test/fixtures/node-axios/delete_content_type.js
generated
vendored
15
test/fixtures/node-axios/delete_content_type.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('localhost:28139', {
|
const response = await axios.post(
|
||||||
headers: {
|
'localhost:28139',
|
||||||
'Content-Type': 'application/json'
|
{},
|
||||||
},
|
{
|
||||||
data: JSON.stringify({})
|
headers: {
|
||||||
});
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
2
test/fixtures/node-axios/get_url_starting_with_http.js
generated
vendored
2
test/fixtures/node-axios/get_url_starting_with_http.js
generated
vendored
@@ -1,3 +1,3 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios('httpbin.org/test');
|
const response = await axios.get('httpbin.org/test');
|
||||||
|
|||||||
17
test/fixtures/node-axios/get_with_all_numerical_data.js
generated
vendored
17
test/fixtures/node-axios/get_with_all_numerical_data.js
generated
vendored
@@ -1,9 +1,12 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/CurlToNode', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/CurlToNode',
|
||||||
'Content-Type': 'application/json',
|
'18233982904',
|
||||||
'Accept': 'application/json'
|
{
|
||||||
},
|
headers: {
|
||||||
data: JSON.stringify(18233982904)
|
'Content-Type': 'application/json',
|
||||||
});
|
'Accept': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
22
test/fixtures/node-axios/get_with_data2.js
generated
vendored
22
test/fixtures/node-axios/get_with_data2.js
generated
vendored
@@ -1,12 +1,16 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.put('http://localhost:28139/v2/alerts_policy_channels.json', {
|
const response = await axios.put(
|
||||||
params: {
|
'http://localhost:28139/v2/alerts_policy_channels.json',
|
||||||
'policy_id': 'policy_id',
|
'',
|
||||||
'channel_ids': 'channel_id'
|
{
|
||||||
},
|
params: {
|
||||||
headers: {
|
'policy_id': 'policy_id',
|
||||||
'X-Api-Key': '{admin_api_key}',
|
'channel_ids': 'channel_id'
|
||||||
'Content-Type': 'application/json'
|
},
|
||||||
|
headers: {
|
||||||
|
'X-Api-Key': '{admin_api_key}',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|||||||
28
test/fixtures/node-axios/get_with_form.js
generated
vendored
28
test/fixtures/node-axios/get_with_form.js
generated
vendored
@@ -1,15 +1,21 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
|
|
||||||
const formData = new FormData();
|
const form = new FormData();
|
||||||
formData.append('from', 'test@tester.com');
|
form.append('from', 'test@tester.com');
|
||||||
formData.append('to', 'devs@tester.net');
|
form.append('to', 'devs@tester.net');
|
||||||
formData.append('subject', 'Hello');
|
form.append('subject', 'Hello');
|
||||||
formData.append('text', 'Testing the converter!');
|
form.append('text', 'Testing the converter!');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/v3', {
|
const response = await axios.post(
|
||||||
auth: {
|
'http://localhost:28139/v3',
|
||||||
username: 'test'
|
form,
|
||||||
},
|
{
|
||||||
data: formData
|
headers: {
|
||||||
});
|
...form.getHeaders()
|
||||||
|
},
|
||||||
|
auth: {
|
||||||
|
username: 'test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
12
test/fixtures/node-axios/j_data_priority_than_f.js
generated
vendored
12
test/fixtures/node-axios/j_data_priority_than_f.js
generated
vendored
@@ -1,12 +1,10 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/post', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/post',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
new URLSearchParams({
|
||||||
},
|
|
||||||
data: {
|
|
||||||
'data1': 'data1',
|
'data1': 'data1',
|
||||||
'data2': 'data2',
|
'data2': 'data2',
|
||||||
'data3': 'data3'
|
'data3': 'data3'
|
||||||
}
|
})
|
||||||
});
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/j_patch_array.js
generated
vendored
15
test/fixtures/node-axios/j_patch_array.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.patch('http://localhost:28139/patch', {
|
const response = await axios.patch(
|
||||||
headers: {
|
'http://localhost:28139/patch',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'item[]=1&item[]=2&item[]=3',
|
||||||
},
|
{
|
||||||
data: 'item[]=1&item[]=2&item[]=3'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
16
test/fixtures/node-axios/j_patch_file_only.js
generated
vendored
16
test/fixtures/node-axios/j_patch_file_only.js
generated
vendored
@@ -2,9 +2,15 @@ const axios = require('axios');
|
|||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const formData = new FormData();
|
const form = new FormData();
|
||||||
formData.append('file1', fs.readFileSync('./fixtures/curl_commands/delete.sh'), './fixtures/curl_commands/delete.sh');
|
form.append('file1', fs.readFileSync('./fixtures/curl_commands/delete.sh'), './fixtures/curl_commands/delete.sh');
|
||||||
|
|
||||||
const response = await axios.patch('http://localhost:28139/patch', {
|
const response = await axios.patch(
|
||||||
data: formData
|
'http://localhost:28139/patch',
|
||||||
});
|
form,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
...form.getHeaders()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
20
test/fixtures/node-axios/j_patch_file_with_data.js
generated
vendored
20
test/fixtures/node-axios/j_patch_file_with_data.js
generated
vendored
@@ -2,11 +2,17 @@ const axios = require('axios');
|
|||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const formData = new FormData();
|
const form = new FormData();
|
||||||
formData.append('file1', fs.readFileSync('./fixtures/curl_commands/delete.sh'), './fixtures/curl_commands/delete.sh');
|
form.append('file1', fs.readFileSync('./fixtures/curl_commands/delete.sh'), './fixtures/curl_commands/delete.sh');
|
||||||
formData.append('form1', 'form+data+1');
|
form.append('form1', 'form+data+1');
|
||||||
formData.append('form2', 'form_data_2');
|
form.append('form2', 'form_data_2');
|
||||||
|
|
||||||
const response = await axios.patch('http://localhost:28139/patch', {
|
const response = await axios.patch(
|
||||||
data: formData
|
'http://localhost:28139/patch',
|
||||||
});
|
form,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
...form.getHeaders()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
12
test/fixtures/node-axios/j_post_data_wo_verb.js
generated
vendored
12
test/fixtures/node-axios/j_post_data_wo_verb.js
generated
vendored
@@ -1,12 +1,10 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/post', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/post',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
new URLSearchParams({
|
||||||
},
|
|
||||||
data: {
|
|
||||||
'data1': 'data1',
|
'data1': 'data1',
|
||||||
'data2': 'data2',
|
'data2': 'data2',
|
||||||
'data3': 'data3'
|
'data3': 'data3'
|
||||||
}
|
})
|
||||||
});
|
);
|
||||||
|
|||||||
18
test/fixtures/node-axios/j_post_form_f.js
generated
vendored
18
test/fixtures/node-axios/j_post_form_f.js
generated
vendored
@@ -1,10 +1,16 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
|
|
||||||
const formData = new FormData();
|
const form = new FormData();
|
||||||
formData.append('d1', 'data1');
|
form.append('d1', 'data1');
|
||||||
formData.append('d2', 'data');
|
form.append('d2', 'data');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/post', {
|
const response = await axios.post(
|
||||||
data: formData
|
'http://localhost:28139/post',
|
||||||
});
|
form,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
...form.getHeaders()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
7
test/fixtures/node-axios/multiline_post_with_data.js
generated
vendored
7
test/fixtures/node-axios/multiline_post_with_data.js
generated
vendored
@@ -2,11 +2,10 @@ const axios = require('axios');
|
|||||||
|
|
||||||
const response = await axios.get('http://localhost:28139/echo/html/', {
|
const response = await axios.get('http://localhost:28139/echo/html/', {
|
||||||
headers: {
|
headers: {
|
||||||
'Origin': 'http://fiddle.jshell.net',
|
'Origin': 'http://fiddle.jshell.net'
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
|
||||||
},
|
},
|
||||||
data: {
|
data: new URLSearchParams({
|
||||||
'msg1': 'value1',
|
'msg1': 'value1',
|
||||||
'msg2': 'value2'
|
'msg2': 'value2'
|
||||||
}
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
22
test/fixtures/node-axios/multipart_post.js
generated
vendored
22
test/fixtures/node-axios/multipart_post.js
generated
vendored
@@ -2,13 +2,17 @@ const axios = require('axios');
|
|||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const formData = new FormData();
|
const form = new FormData();
|
||||||
formData.append('attributes', '{"name":"tigers.jpeg", "parent":{"id":"11446498"}}');
|
form.append('attributes', '{"name":"tigers.jpeg", "parent":{"id":"11446498"}}');
|
||||||
formData.append('file', fs.readFileSync('myfile.jpg'), 'myfile.jpg');
|
form.append('file', fs.readFileSync('myfile.jpg'), 'myfile.jpg');
|
||||||
|
|
||||||
const response = await axios.post('https://localhost:28139/api/2.0/files/content', {
|
const response = await axios.post(
|
||||||
headers: {
|
'https://localhost:28139/api/2.0/files/content',
|
||||||
'Authorization': 'Bearer ACCESS_TOKEN'
|
form,
|
||||||
},
|
{
|
||||||
data: formData
|
headers: {
|
||||||
});
|
...form.getHeaders(),
|
||||||
|
'Authorization': 'Bearer ACCESS_TOKEN'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
24
test/fixtures/node-axios/multipart_with_headers.js
generated
vendored
24
test/fixtures/node-axios/multipart_with_headers.js
generated
vendored
@@ -2,14 +2,18 @@ const axios = require('axios');
|
|||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const formData = new FormData();
|
const form = new FormData();
|
||||||
formData.append('attributes', '{"name":"tigers.jpeg", "parent":{"id":"11446498"}}');
|
form.append('attributes', '{"name":"tigers.jpeg", "parent":{"id":"11446498"}}');
|
||||||
formData.append('file', fs.readFileSync('myfile.jpg'), 'myfile.jpg');
|
form.append('file', fs.readFileSync('myfile.jpg'), 'myfile.jpg');
|
||||||
|
|
||||||
const response = await axios.post('https://localhost:28139/api/2.0/files/content', {
|
const response = await axios.post(
|
||||||
headers: {
|
'https://localhost:28139/api/2.0/files/content',
|
||||||
'Authorization': 'Bearer ACCESS_TOKEN',
|
form,
|
||||||
'X-Nice': 'Header'
|
{
|
||||||
},
|
headers: {
|
||||||
data: formData
|
...form.getHeaders(),
|
||||||
});
|
'Authorization': 'Bearer ACCESS_TOKEN',
|
||||||
|
'X-Nice': 'Header'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/multiple_d_post.js
generated
vendored
15
test/fixtures/node-axios/multiple_d_post.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('https://localhost:28139/webservices/rest.php', {
|
const response = await axios.post(
|
||||||
headers: {
|
'https://localhost:28139/webservices/rest.php',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'version=1.2&auth_user=fdgxf&auth_pwd=oxfdscds&json_data={ "operation": "core/get", "class": "Software", "key": "key" }',
|
||||||
},
|
{
|
||||||
data: 'version=1.2&auth_user=fdgxf&auth_pwd=oxfdscds&json_data={ "operation": "core/get", "class": "Software", "key": "key" }'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
29
test/fixtures/node-axios/patch.js
generated
vendored
29
test/fixtures/node-axios/patch.js
generated
vendored
@@ -1,16 +1,9 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.patch('http://localhost:28139/go/api/agents/adb9540a-b954-4571-9d9b-2f330739d4da', {
|
const response = await axios.patch(
|
||||||
headers: {
|
'http://localhost:28139/go/api/agents/adb9540a-b954-4571-9d9b-2f330739d4da',
|
||||||
'Accept': 'application/vnd.go.cd.v4+json',
|
// '{\n "hostname": "agent02.example.com",\n "agent_config_state": "Enabled",\n "resources": ["Java","Linux"],\n "environments": ["Dev"]\n }',
|
||||||
'Content-Type': 'application/json'
|
{
|
||||||
},
|
|
||||||
auth: {
|
|
||||||
username: 'username',
|
|
||||||
password: 'password'
|
|
||||||
},
|
|
||||||
// data: '{\n "hostname": "agent02.example.com",\n "agent_config_state": "Enabled",\n "resources": ["Java","Linux"],\n "environments": ["Dev"]\n }',
|
|
||||||
data: JSON.stringify({
|
|
||||||
'hostname': 'agent02.example.com',
|
'hostname': 'agent02.example.com',
|
||||||
'agent_config_state': 'Enabled',
|
'agent_config_state': 'Enabled',
|
||||||
'resources': [
|
'resources': [
|
||||||
@@ -20,5 +13,15 @@ const response = await axios.patch('http://localhost:28139/go/api/agents/adb9540
|
|||||||
'environments': [
|
'environments': [
|
||||||
'Dev'
|
'Dev'
|
||||||
]
|
]
|
||||||
})
|
},
|
||||||
});
|
{
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/vnd.go.cd.v4+json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
auth: {
|
||||||
|
username: 'username',
|
||||||
|
password: 'password'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
20
test/fixtures/node-axios/post_basic_auth_url_encoded_data.js
generated
vendored
20
test/fixtures/node-axios/post_basic_auth_url_encoded_data.js
generated
vendored
@@ -1,14 +1,14 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/api/oauth/token/', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/api/oauth/token/',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
new URLSearchParams({
|
||||||
},
|
|
||||||
auth: {
|
|
||||||
username: 'foo',
|
|
||||||
password: 'bar'
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
'grant_type': 'client_credentials'
|
'grant_type': 'client_credentials'
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
auth: {
|
||||||
|
username: 'foo',
|
||||||
|
password: 'bar'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|||||||
17
test/fixtures/node-axios/post_binary_file.js
generated
vendored
17
test/fixtures/node-axios/post_binary_file.js
generated
vendored
@@ -1,9 +1,12 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/american-art/query', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/american-art/query',
|
||||||
'Content-type': 'application/sparql-query',
|
'@./sample.sparql',
|
||||||
'Accept': 'application/sparql-results+json'
|
{
|
||||||
},
|
headers: {
|
||||||
data: '@./sample.sparql'
|
'Content-type': 'application/sparql-query',
|
||||||
});
|
'Accept': 'application/sparql-results+json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
67
test/fixtures/node-axios/post_data_binary_with_equals.js
generated
vendored
67
test/fixtures/node-axios/post_data_binary_with_equals.js
generated
vendored
@@ -1,35 +1,8 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/api/service.svc', {
|
const response = await axios.post(
|
||||||
params: {
|
'http://localhost:28139/api/service.svc',
|
||||||
'action': 'CreateItem',
|
{
|
||||||
'ID': '-37',
|
|
||||||
'AC': '1'
|
|
||||||
},
|
|
||||||
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'
|
|
||||||
},
|
|
||||||
data: JSON.stringify({
|
|
||||||
'__type': 'CreateItemJsonRequest:#Exchange',
|
'__type': 'CreateItemJsonRequest:#Exchange',
|
||||||
'Header': {
|
'Header': {
|
||||||
'__type': 'JsonRequestHeaders:#Exchange',
|
'__type': 'JsonRequestHeaders:#Exchange',
|
||||||
@@ -77,5 +50,35 @@ const response = await axios.post('http://localhost:28139/api/service.svc', {
|
|||||||
'MessageDisposition': 'SendAndSaveCopy',
|
'MessageDisposition': 'SendAndSaveCopy',
|
||||||
'ComposeOperation': 'newMail'
|
'ComposeOperation': 'newMail'
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
});
|
{
|
||||||
|
params: {
|
||||||
|
'action': 'CreateItem',
|
||||||
|
'ID': '-37',
|
||||||
|
'AC': '1'
|
||||||
|
},
|
||||||
|
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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
12
test/fixtures/node-axios/post_empty.js
generated
vendored
12
test/fixtures/node-axios/post_empty.js
generated
vendored
@@ -1,7 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'',
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/post_escaped_double_quotes_in_single_quotes.js
generated
vendored
15
test/fixtures/node-axios/post_escaped_double_quotes_in_single_quotes.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'foo=\\"bar\\"',
|
||||||
},
|
{
|
||||||
data: 'foo=\\"bar\\"'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/post_escaped_single_quotes_in_double_quotes.js
generated
vendored
15
test/fixtures/node-axios/post_escaped_single_quotes_in_double_quotes.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'foo=\\\'bar\\\'',
|
||||||
},
|
{
|
||||||
data: 'foo=\\\'bar\\\''
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
18
test/fixtures/node-axios/post_form.js
generated
vendored
18
test/fixtures/node-axios/post_form.js
generated
vendored
@@ -1,10 +1,16 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
|
|
||||||
const formData = new FormData();
|
const form = new FormData();
|
||||||
formData.append('username', 'davidwalsh');
|
form.append('username', 'davidwalsh');
|
||||||
formData.append('password', 'something');
|
form.append('password', 'something');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/post-to-me.php', {
|
const response = await axios.post(
|
||||||
data: formData
|
'http://localhost:28139/post-to-me.php',
|
||||||
});
|
form,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
...form.getHeaders()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
16
test/fixtures/node-axios/post_image.js
generated
vendored
16
test/fixtures/node-axios/post_image.js
generated
vendored
@@ -2,9 +2,15 @@ const axios = require('axios');
|
|||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const formData = new FormData();
|
const form = new FormData();
|
||||||
formData.append('image', fs.readFileSync('image.jpg'), 'image.jpg');
|
form.append('image', fs.readFileSync('image.jpg'), 'image.jpg');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/targetservice', {
|
const response = await axios.post(
|
||||||
data: formData
|
'http://localhost:28139/targetservice',
|
||||||
});
|
form,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
...form.getHeaders()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
21
test/fixtures/node-axios/post_json.js
generated
vendored
21
test/fixtures/node-axios/post_json.js
generated
vendored
@@ -1,12 +1,15 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('https://localhost:28139', {
|
const response = await axios.post(
|
||||||
headers: {
|
'https://localhost:28139',
|
||||||
'Content-Type': 'application/json',
|
// '{ "drink": "coffe" }',
|
||||||
'Accept': 'application/json'
|
{
|
||||||
},
|
|
||||||
// data: '{ "drink": "coffe" }',
|
|
||||||
data: JSON.stringify({
|
|
||||||
'drink': 'coffe'
|
'drink': 'coffe'
|
||||||
})
|
},
|
||||||
});
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
21
test/fixtures/node-axios/post_json_multiple_headers.js
generated
vendored
21
test/fixtures/node-axios/post_json_multiple_headers.js
generated
vendored
@@ -1,14 +1,17 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('https://localhost:28139/rest/login-sessions', {
|
const response = await axios.post(
|
||||||
headers: {
|
'https://localhost:28139/rest/login-sessions',
|
||||||
'Content-Type': 'application/json',
|
// '{"userName":"username123","password":"password123", "authLoginDomain":"local"}',
|
||||||
'X-API-Version': '200'
|
{
|
||||||
},
|
|
||||||
// data: '{"userName":"username123","password":"password123", "authLoginDomain":"local"}',
|
|
||||||
data: JSON.stringify({
|
|
||||||
'userName': 'username123',
|
'userName': 'username123',
|
||||||
'password': 'password123',
|
'password': 'password123',
|
||||||
'authLoginDomain': 'local'
|
'authLoginDomain': 'local'
|
||||||
})
|
},
|
||||||
});
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-API-Version': '200'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/post_number.js
generated
vendored
15
test/fixtures/node-axios/post_number.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'123',
|
||||||
},
|
{
|
||||||
data: '123'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
12
test/fixtures/node-axios/post_quotes_inside_data.js
generated
vendored
12
test/fixtures/node-axios/post_quotes_inside_data.js
generated
vendored
@@ -1,10 +1,8 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('localhost:28139', {
|
const response = await axios.post(
|
||||||
headers: {
|
'localhost:28139',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
new URLSearchParams({
|
||||||
},
|
|
||||||
data: {
|
|
||||||
'field': 'don\'t you like quotes'
|
'field': 'don\'t you like quotes'
|
||||||
}
|
})
|
||||||
});
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/post_same_field_multiple_times.js
generated
vendored
15
test/fixtures/node-axios/post_same_field_multiple_times.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'foo=bar&foo=&foo=barbar',
|
||||||
},
|
{
|
||||||
data: 'foo=bar&foo=&foo=barbar'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
28
test/fixtures/node-axios/post_with_browser_headers.js
generated
vendored
28
test/fixtures/node-axios/post_with_browser_headers.js
generated
vendored
@@ -1,15 +1,19 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/ajax/demo_post.asp', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/ajax/demo_post.asp',
|
||||||
'Origin': 'http://www.w3schools.com',
|
'',
|
||||||
'Accept-Encoding': 'gzip, deflate',
|
{
|
||||||
'Accept-Language': 'en-US,en;q=0.8',
|
headers: {
|
||||||
'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',
|
'Origin': 'http://www.w3schools.com',
|
||||||
'Accept': '*/*',
|
'Accept-Encoding': 'gzip, deflate',
|
||||||
'Referer': 'http://www.w3schools.com/ajax/tryit_view.asp?x=0.07944501144811511',
|
'Accept-Language': 'en-US,en;q=0.8',
|
||||||
'Cookie': '_gat=1; ASPSESSIONIDACCRDTDC=MCMDKFMBLLLHGKCGNMKNGPKI; _ga=GA1.2.1424920226.1419478126',
|
'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',
|
||||||
'Connection': 'keep-alive',
|
'Accept': '*/*',
|
||||||
'Content-Length': '0'
|
'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'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|||||||
14
test/fixtures/node-axios/post_with_colon_in_header.js
generated
vendored
14
test/fixtures/node-axios/post_with_colon_in_header.js
generated
vendored
@@ -1,8 +1,12 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/endpoint', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/endpoint',
|
||||||
'Content-Type': 'application/json',
|
'',
|
||||||
'key': 'abcdefg'
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'key': 'abcdefg'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|||||||
31
test/fixtures/node-axios/post_with_data-ascii.js
generated
vendored
31
test/fixtures/node-axios/post_with_data-ascii.js
generated
vendored
@@ -1,19 +1,22 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/echo/html/', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/echo/html/',
|
||||||
'Origin': 'http://fiddle.jshell.net',
|
new URLSearchParams({
|
||||||
'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'
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
'msg1': 'wow',
|
'msg1': 'wow',
|
||||||
'msg2': 'such'
|
'msg2': 'such'
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
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'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/post_with_data_binary.js
generated
vendored
15
test/fixtures/node-axios/post_with_data_binary.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/post', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/post',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'{"title":"china1"}',
|
||||||
},
|
{
|
||||||
data: '{"title":"china1"}'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/post_with_data_raw.js
generated
vendored
15
test/fixtures/node-axios/post_with_data_raw.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/post', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/post',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'msg1=wow&msg2=such&msg3=@rawmsg',
|
||||||
},
|
{
|
||||||
data: 'msg1=wow&msg2=such&msg3=@rawmsg'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/post_with_data_with_percent_sign.js
generated
vendored
15
test/fixtures/node-axios/post_with_data_with_percent_sign.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('https://localhost:28139/post', {
|
const response = await axios.post(
|
||||||
headers: {
|
'https://localhost:28139/post',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'secret=*%5*!',
|
||||||
},
|
{
|
||||||
data: 'secret=*%5*!'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/post_with_double_quotes_inside_single_quotes.js
generated
vendored
15
test/fixtures/node-axios/post_with_double_quotes_inside_single_quotes.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'foo="bar"',
|
||||||
},
|
{
|
||||||
data: 'foo="bar"'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/post_with_escaped_double_quotes.js
generated
vendored
15
test/fixtures/node-axios/post_with_escaped_double_quotes.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'foo="bar"',
|
||||||
},
|
{
|
||||||
data: 'foo="bar"'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
30
test/fixtures/node-axios/post_with_extra_whitespace.js
generated
vendored
30
test/fixtures/node-axios/post_with_extra_whitespace.js
generated
vendored
@@ -2,17 +2,21 @@ const axios = require('axios');
|
|||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const formData = new FormData();
|
const form = new FormData();
|
||||||
formData.append('files', fs.readFileSync('47.htz'), '47.htz');
|
form.append('files', fs.readFileSync('47.htz'), '47.htz');
|
||||||
formData.append('name', '47');
|
form.append('name', '47');
|
||||||
formData.append('oldMediaId', '47');
|
form.append('oldMediaId', '47');
|
||||||
formData.append('updateInLayouts', '1');
|
form.append('updateInLayouts', '1');
|
||||||
formData.append('deleteOldRevisions', '1');
|
form.append('deleteOldRevisions', '1');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/api/library', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/api/library',
|
||||||
'accept': 'application/json',
|
form,
|
||||||
'Content-Type': 'multipart/form-data'
|
{
|
||||||
},
|
headers: {
|
||||||
data: formData
|
...form.getHeaders(),
|
||||||
});
|
'accept': 'application/json',
|
||||||
|
'Content-Type': 'multipart/form-data'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
29
test/fixtures/node-axios/post_with_quotes_anywhere.js
generated
vendored
29
test/fixtures/node-axios/post_with_quotes_anywhere.js
generated
vendored
@@ -1,15 +1,18 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('https://localhost:28139', {
|
const response = await axios.post(
|
||||||
headers: {
|
'https://localhost:28139',
|
||||||
'A': '\'\'a\'',
|
'a=b&c="&d=\'',
|
||||||
'B': '"',
|
{
|
||||||
'Cookie': 'x=1\'; y=2"',
|
headers: {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'A': '\'\'a\'',
|
||||||
},
|
'B': '"',
|
||||||
auth: {
|
'Cookie': 'x=1\'; y=2"',
|
||||||
username: 'ol\'',
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
password: 'asd"'
|
},
|
||||||
},
|
auth: {
|
||||||
data: 'a=b&c="&d=\''
|
username: 'ol\'',
|
||||||
});
|
password: 'asd"'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/post_with_single_quotes_inside_double_quotes.js
generated
vendored
15
test/fixtures/node-axios/post_with_single_quotes_inside_double_quotes.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'foo=\'bar\'',
|
||||||
},
|
{
|
||||||
data: 'foo=\'bar\''
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
31
test/fixtures/node-axios/post_with_urlencoded_data.js
generated
vendored
31
test/fixtures/node-axios/post_with_urlencoded_data.js
generated
vendored
@@ -1,19 +1,22 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/echo/html/', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/echo/html/',
|
||||||
'Origin': 'http://fiddle.jshell.net',
|
new URLSearchParams({
|
||||||
'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'
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
'msg1': 'wow',
|
'msg1': 'wow',
|
||||||
'msg2': 'such'
|
'msg2': 'such'
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
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'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|||||||
29
test/fixtures/node-axios/post_with_urlencoded_data_and_headers.js
generated
vendored
29
test/fixtures/node-axios/post_with_urlencoded_data_and_headers.js
generated
vendored
@@ -1,17 +1,8 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/api/Listing.svc/PropertySearch_Post', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/api/Listing.svc/PropertySearch_Post',
|
||||||
'Origin': 'http://www.realtor.ca',
|
new URLSearchParams({
|
||||||
'Accept-Encoding': 'gzip, deflate',
|
|
||||||
'Accept-Language': 'en-US,en;q=0.8',
|
|
||||||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36',
|
|
||||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
||||||
'Accept': '*/*',
|
|
||||||
'Referer': 'http://www.realtor.ca/Residential/Map.aspx',
|
|
||||||
'Connection': 'keep-alive'
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
'CultureId': '1',
|
'CultureId': '1',
|
||||||
'ApplicationId': '1',
|
'ApplicationId': '1',
|
||||||
'RecordsPerPage': '200',
|
'RecordsPerPage': '200',
|
||||||
@@ -33,5 +24,17 @@ const response = await axios.post('http://localhost:28139/api/Listing.svc/Proper
|
|||||||
'Latitude': '43.6552047278685',
|
'Latitude': '43.6552047278685',
|
||||||
'ZoomLevel': '13',
|
'ZoomLevel': '13',
|
||||||
'CurrentPage': '1'
|
'CurrentPage': '1'
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'Origin': 'http://www.realtor.ca',
|
||||||
|
'Accept-Encoding': 'gzip, deflate',
|
||||||
|
'Accept-Language': 'en-US,en;q=0.8',
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36',
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||||
|
'Accept': '*/*',
|
||||||
|
'Referer': 'http://www.realtor.ca/Residential/Map.aspx',
|
||||||
|
'Connection': 'keep-alive'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/post_xpost.js
generated
vendored
15
test/fixtures/node-axios/post_xpost.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.post('http://localhost:28139/api/xxxxxxxxxxxxxxxx', {
|
const response = await axios.post(
|
||||||
headers: {
|
'http://localhost:28139/api/xxxxxxxxxxxxxxxx',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'{"keywords":"php","page":1,"searchMode":1}',
|
||||||
},
|
{
|
||||||
data: '{"keywords":"php","page":1,"searchMode":1}'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
23
test/fixtures/node-axios/put_basic_auth_json_data.js
generated
vendored
23
test/fixtures/node-axios/put_basic_auth_json_data.js
generated
vendored
@@ -1,12 +1,15 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.put('http://localhost:28139/test/_security', {
|
const response = await axios.put(
|
||||||
headers: {
|
'http://localhost:28139/test/_security',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'{"admins":{"names":[], "roles":[]}, "readers":{"names":["joe"],"roles":[]}}',
|
||||||
},
|
{
|
||||||
auth: {
|
headers: {
|
||||||
username: 'admin',
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
password: '123'
|
},
|
||||||
},
|
auth: {
|
||||||
data: '{"admins":{"names":[], "roles":[]}, "readers":{"names":["joe"],"roles":[]}}'
|
username: 'admin',
|
||||||
});
|
password: '123'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
19
test/fixtures/node-axios/put_with_T_option.js
generated
vendored
19
test/fixtures/node-axios/put_with_T_option.js
generated
vendored
@@ -1,15 +1,18 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.put('http://localhost:28139/twitter/_mapping/user?pretty', {
|
const response = await axios.put(
|
||||||
headers: {
|
'http://localhost:28139/twitter/_mapping/user?pretty',
|
||||||
'Content-Type': 'application/json'
|
// '{"properties": {"email": {"type": "keyword"}}}',
|
||||||
},
|
{
|
||||||
// data: '{"properties": {"email": {"type": "keyword"}}}',
|
|
||||||
data: JSON.stringify({
|
|
||||||
'properties': {
|
'properties': {
|
||||||
'email': {
|
'email': {
|
||||||
'type': 'keyword'
|
'type': 'keyword'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
});
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
15
test/fixtures/node-axios/put_with_file.js
generated
vendored
15
test/fixtures/node-axios/put_with_file.js
generated
vendored
@@ -1,8 +1,11 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.put('http://localhost:28139/upload', {
|
const response = await axios.put(
|
||||||
headers: {
|
'http://localhost:28139/upload',
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'@new_file',
|
||||||
},
|
{
|
||||||
data: '@new_file'
|
headers: {
|
||||||
});
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
19
test/fixtures/node-axios/put_xput.js
generated
vendored
19
test/fixtures/node-axios/put_xput.js
generated
vendored
@@ -1,15 +1,18 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.put('http://localhost:28139/twitter/_mapping/user?pretty', {
|
const response = await axios.put(
|
||||||
headers: {
|
'http://localhost:28139/twitter/_mapping/user?pretty',
|
||||||
'Content-Type': 'application/json'
|
// '{"properties": {"email": {"type": "keyword"}}}',
|
||||||
},
|
{
|
||||||
// data: '{"properties": {"email": {"type": "keyword"}}}',
|
|
||||||
data: JSON.stringify({
|
|
||||||
'properties': {
|
'properties': {
|
||||||
'email': {
|
'email': {
|
||||||
'type': 'keyword'
|
'type': 'keyword'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
});
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
4
test/fixtures/node-axios/strange_http_method.js
generated
vendored
4
test/fixtures/node-axios/strange_http_method.js
generated
vendored
@@ -1,5 +1,3 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
const response = await axios.request('localhost:28139', {
|
const response = await axios('localhost:28139');
|
||||||
method: 'what'
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user