Skip to content

Commit

Permalink
Merge pull request #919 from burn-notice/remove_headers_that_are_empty
Browse files Browse the repository at this point in the history
don't send empty headers
  • Loading branch information
enyo committed Apr 28, 2015
2 parents 4b93b1b + 441bb4c commit 5ebbab8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/dropzone.coffee
Expand Up @@ -1179,7 +1179,8 @@ class Dropzone extends Emitter

extend headers, @options.headers if @options.headers

xhr.setRequestHeader headerName, headerValue for headerName, headerValue of headers
for headerName, headerValue of headers
xhr.setRequestHeader headerName, headerValue if headerValue

formData = new FormData()

Expand Down
5 changes: 5 additions & 0 deletions test/test.coffee
Expand Up @@ -1583,6 +1583,11 @@ describe "Dropzone", ->
dropzone.uploadFile mockFile
requests[0].requestHeaders["Foo-Header"].should.eql 'foobar'

it "should not set headers on the xhr object that are empty", ->
dropzone.options.headers = {"X-Requested-With": null}
dropzone.uploadFile mockFile
Object.keys(requests[0].requestHeaders).should.not.contain("X-Requested-With")

it "should properly use the paramName without [n] as file upload if uploadMultiple is false", (done) ->
dropzone.options.uploadMultiple = false
dropzone.options.paramName = "myName"
Expand Down

0 comments on commit 5ebbab8

Please sign in to comment.