2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00

Merge pull request #22 from nnarhinen/formdata-content-type

Fixing issue with Content-Type when uploading FormData
This commit is contained in:
Matt Zabriskie
2014-11-04 10:47:46 -07:00
2 changed files with 15 additions and 0 deletions
+4
View File
@@ -21,6 +21,10 @@ module.exports = function xhrAdapter(resolve, reject, config) {
config.headers || {}
);
if (utils.isFormData(data)) {
delete headers['Content-Type']; // Let the browser set it
}
// Create the request
var request = new(XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
request.open(config.method, buildUrl(config.url, config.params), true);
+11
View File
@@ -22,6 +22,16 @@ 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
*
@@ -188,6 +198,7 @@ function merge(obj1/*, obj2, obj3, ...*/) {
module.exports = {
isArray: isArray,
isArrayBuffer: isArrayBuffer,
isFormData: isFormData,
isArrayBufferView: isArrayBufferView,
isString: isString,
isNumber: isNumber,