Permalink
Browse files

Merge pull request #361 from danjenkins/master

Don't create a Content-Length header if we already have it set
  • Loading branch information...
2 parents 9a3129c + 61e3850 commit 4a8150744544300f392dbf00d9f185c62ac48344 @mikeal mikeal committed Nov 5, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 main.js
View
@@ -290,6 +290,7 @@ Request.prototype.init = function (options) {
length = self.body.length
}
if (length) {
+ if(!self.headers['content-length'] && !self.headers['Content-Length'])
self.headers['content-length'] = length
} else {
throw new Error('Argument error, options.body.')
@@ -509,13 +510,12 @@ Request.prototype.start = function () {
self.href = self.uri.href
if (log) log('%method %href', self)
- if (self.src && self.src.stat && self.src.stat.size) {
+ if (self.src && self.src.stat && self.src.stat.size && !self.headers['content-length'] && !self.headers['Content-Length']) {
self.headers['content-length'] = self.src.stat.size
}
if (self._aws) {
self.aws(self._aws, true)
}
-
self.req = self.httpModule.request(self, function (response) {
if (response.connection.listeners('error').indexOf(self._parserErrorHandler) === -1) {
response.connection.once('error', self._parserErrorHandler)

0 comments on commit 4a81507

Please sign in to comment.