Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting of content-type #1544

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions lib/adapters/xhr.js
Expand Up @@ -130,13 +130,7 @@ module.exports = function xhrAdapter(config) {
// Add headers to the request
if ('setRequestHeader' in request) {
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
// Remove Content-Type if data is undefined
delete requestHeaders[key];
} else {
// Otherwise add header to the request
request.setRequestHeader(key, val);
}
request.setRequestHeader(key, val);
});
}

Expand Down
10 changes: 5 additions & 5 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "axios",
"version": "0.18.0",
"name": "aaxios",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaxios -> axios

"version": "0.18.1",
"description": "Promise based HTTP client for the browser and node.js",
"main": "index.js",
"scripts": {
Expand All @@ -16,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/axios/axios.git"
"url": "https://github.com/andrew-templeton/axios"
},
"keywords": [
"xhr",
Expand All @@ -28,9 +28,9 @@
"author": "Matt Zabriskie",
"license": "MIT",
"bugs": {
"url": "https://github.com/axios/axios/issues"
"url": "https://github.com/andrew-templeton/axios/issues"
},
"homepage": "https://github.com/axios/axios",
"homepage": "https://github.com/andrew-templeton/axios/axios",
"devDependencies": {
"bundlesize": "^0.17.0",
"coveralls": "^3.0.0",
Expand Down
9 changes: 0 additions & 9 deletions test/specs/headers.spec.js
Expand Up @@ -69,15 +69,6 @@ describe('headers', function () {
});
});

it('should remove content-type if data is empty', function (done) {
axios.post('/foo');

getAjaxRequest().then(function (request) {
testHeaderValue(request.requestHeaders, 'Content-Type', undefined);
done();
});
});

it('should preserve content-type if data is false', function (done) {
axios.post('/foo', false);

Expand Down