Skip to content

Commit

Permalink
Set Content-Length to 0 if not sending a body
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Duncan committed Dec 16, 2014
1 parent 794e590 commit 0f48a3a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class ScopedClient
sendingData = reqBody and reqBody.length > 0
headers.Host = @options.hostname

if reqBody?
headers['Content-Length'] = Buffer.byteLength(reqBody, @options.encoding)
headers['Content-Length'] = if sendingData then Buffer.byteLength(reqBody, @options.encoding) else 0

if @options.auth
headers['Authorization'] = 'Basic ' + new Buffer(@options.auth).toString('base64');
Expand Down

0 comments on commit 0f48a3a

Please sign in to comment.