Skip to content

Commit

Permalink
Merge pull request #90 from bobholt/no-auto-content
Browse files Browse the repository at this point in the history
do not auto-set json content-type
  • Loading branch information
naugtur committed Aug 19, 2015
2 parents f7a4a45 + 0453918 commit 3ff330e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function createXHR(options, callback) {

return body
}

var failureResponse = {
body: undefined,
headers: {},
Expand All @@ -51,7 +51,7 @@ function createXHR(options, callback) {
url: uri,
rawRequest: xhr
}

function errorFunc(evt) {
clearTimeout(timeoutTimer)
if(!(evt instanceof Error)){
Expand All @@ -74,7 +74,7 @@ function createXHR(options, callback) {
}
var response = failureResponse
var err = null

if (status !== 0){
response = {
body: getBody(),
Expand All @@ -91,9 +91,9 @@ function createXHR(options, callback) {
err = new Error("Internal XMLHttpRequest Error")
}
callback(err, response, response.body)

}

if (typeof options === "string") {
options = { uri: options }
}
Expand Down Expand Up @@ -128,7 +128,7 @@ function createXHR(options, callback) {
isJson = true
headers["accept"] || headers["Accept"] || (headers["Accept"] = "application/json") //Don't override existing accept header declared by user
if (method !== "GET" && method !== "HEAD") {
headers["Content-Type"] = "application/json"
headers["content-type"] || headers["Content-Type"] || (headers["Content-Type"] = "application/json") //Don't override existing accept header declared by user
body = JSON.stringify(options.json)
}
}
Expand Down Expand Up @@ -170,8 +170,8 @@ function createXHR(options, callback) {
if ("responseType" in options) {
xhr.responseType = options.responseType
}
if ("beforeSend" in options &&

if ("beforeSend" in options &&
typeof options.beforeSend === "function"
) {
options.beforeSend(xhr)
Expand Down

0 comments on commit 3ff330e

Please sign in to comment.