mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
This reverts commit 73e3bdb883.
This commit is contained in:
Vendored
-3
@@ -107,9 +107,6 @@ export interface AxiosRequestConfig<D = any> {
|
||||
transitional?: TransitionalOptions;
|
||||
signal?: AbortSignal;
|
||||
insecureHTTPParser?: boolean;
|
||||
env?: {
|
||||
FormData?: new (...args: any[]) => object;
|
||||
};
|
||||
}
|
||||
|
||||
export interface HeadersDefaults {
|
||||
|
||||
@@ -87,9 +87,7 @@ module.exports = function httpAdapter(config) {
|
||||
headers['User-Agent'] = 'axios/' + VERSION;
|
||||
}
|
||||
|
||||
if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
|
||||
Object.assign(headers, data.getHeaders());
|
||||
} else if (data && !utils.isStream(data)) {
|
||||
if (data && !utils.isStream(data)) {
|
||||
if (Buffer.isBuffer(data)) {
|
||||
// Nothing to do...
|
||||
} else if (utils.isArrayBuffer(data)) {
|
||||
|
||||
+1
-11
@@ -3,7 +3,6 @@
|
||||
var utils = require('./utils');
|
||||
var normalizeHeaderName = require('./helpers/normalizeHeaderName');
|
||||
var enhanceError = require('./core/enhanceError');
|
||||
var toFormData = require('./helpers/toFormData');
|
||||
|
||||
var DEFAULT_CONTENT_TYPE = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
@@ -72,17 +71,10 @@ var defaults = {
|
||||
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
|
||||
return data.toString();
|
||||
}
|
||||
|
||||
var isObjectPayload = utils.isObject(data);
|
||||
var contentType = headers && headers['Content-Type'];
|
||||
|
||||
if ( isObjectPayload && contentType === 'multipart/form-data' ) {
|
||||
return toFormData(data, new (this.env && this.env.FormData || FormData));
|
||||
} else if ( isObjectPayload || contentType === 'application/json' ) {
|
||||
if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
|
||||
setContentTypeIfUnset(headers, 'application/json');
|
||||
return stringifySafely(data);
|
||||
}
|
||||
|
||||
return data;
|
||||
}],
|
||||
|
||||
@@ -120,8 +112,6 @@ var defaults = {
|
||||
maxContentLength: -1,
|
||||
maxBodyLength: -1,
|
||||
|
||||
env: {},
|
||||
|
||||
validateStatus: function validateStatus(status) {
|
||||
return status >= 200 && status < 300;
|
||||
},
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var utils = require('../utils');
|
||||
|
||||
function combinedKey(parentKey, elKey) {
|
||||
return parentKey + '.' + elKey;
|
||||
}
|
||||
@@ -13,7 +11,7 @@ function buildFormData(formData, data, parentKey) {
|
||||
});
|
||||
} else if (
|
||||
typeof data === 'object' &&
|
||||
!(utils.isFile(data) || data === null)
|
||||
!(data instanceof File || data === null)
|
||||
) {
|
||||
Object.keys(data).forEach(function buildObject(key) {
|
||||
buildFormData(
|
||||
@@ -46,12 +44,10 @@ function buildFormData(formData, data, parentKey) {
|
||||
* type FormVal = FormDataNest | FormDataPrimitive
|
||||
*
|
||||
* @param {FormVal} data
|
||||
* @param {?Object} formData
|
||||
*/
|
||||
|
||||
module.exports = function getFormData(data, formData) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
formData = formData || new FormData();
|
||||
module.exports = function getFormData(data) {
|
||||
var formData = new FormData();
|
||||
|
||||
buildFormData(formData, data);
|
||||
|
||||
|
||||
+9
-15
@@ -47,6 +47,15 @@ function isArrayBuffer(val) {
|
||||
return toString.call(val) === '[object ArrayBuffer]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a FormData
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is an FormData, otherwise false
|
||||
*/
|
||||
function isFormData(val) {
|
||||
return toString.call(val) === '[object FormData]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a view on an ArrayBuffer
|
||||
@@ -159,21 +168,6 @@ function isStream(val) {
|
||||
return isObject(val) && isFunction(val.pipe);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a FormData
|
||||
*
|
||||
* @param {Object} thing The value to test
|
||||
* @returns {boolean} True if value is an FormData, otherwise false
|
||||
*/
|
||||
function isFormData(thing) {
|
||||
var pattern = '[object FormData]';
|
||||
return thing && (
|
||||
(typeof FormData === 'function' && thing instanceof FormData) ||
|
||||
toString.call(thing) === pattern ||
|
||||
(isFunction(thing.toString) && thing.toString() === pattern)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a URLSearchParams object
|
||||
*
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var toFormData = require("../../../lib/helpers/toFormData");
|
||||
|
||||
describe("toFormData", function () {
|
||||
it("Convert nested data object to FormData", function () {
|
||||
it("Convert nested data object to FormDAta", function () {
|
||||
var o = {
|
||||
val: 123,
|
||||
nested: {
|
||||
|
||||
Reference in New Issue
Block a user