Skip to content

Commit

Permalink
don't send empty headers
Browse files Browse the repository at this point in the history
  • Loading branch information
phoet committed Apr 22, 2015
1 parent b82c479 commit 441bb4c
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
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,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
Original file line number Diff line number Diff line change
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 441bb4c

Please sign in to comment.