Skip to content

Commit

Permalink
Copy headers so that they survive mutation.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeal committed Aug 12, 2011
1 parent 7b2f788 commit f8eb2e2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ function isReadStream (rs) {
}
}

function copy (obj) {
var o = {}
for (i in obj) o[i] = obj[i]
return o
}

var isUrl = /^https?:/

var globalPool = {}
Expand Down Expand Up @@ -103,7 +109,7 @@ Request.prototype.request = function () {
options.maxRedirects = (options.maxRedirects !== undefined) ? options.maxRedirects : 10
options.followRedirect = (options.followRedirect !== undefined) ? options.followRedirect : true

options.headers = options.headers || {}
options.headers = options.headers ? copy(options.headers) : {}

var setHost = false
if (!options.headers.host) {
Expand Down

0 comments on commit f8eb2e2

Please sign in to comment.