Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fixing neverending redirect loop #368

Closed
wants to merge 1 commit into from

1 participant

@jondot

issue #311.
looks like Host header is transmitted on the wire as lowercast 'host' which confuses some servers.
RFC does state the host header as uppercase 'Host', so I amended all instances of headers.host to headers.Host.

Hope this helps.

@jondot

closing due to alternate way suggested by @mikeal (thanks).

@jondot jondot closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 9, 2012
  1. @jondot

    fixing #311

    jondot authored
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 6 deletions.
  1. +6 −6 main.js
View
12 main.js
@@ -181,12 +181,12 @@ Request.prototype.init = function (options) {
self.headers = self.headers ? copy(self.headers) : {}
self.setHost = false
- if (!self.headers.host) {
- self.headers.host = self.uri.hostname
+ if (!self.headers.Host) {
+ self.headers.Host = self.uri.hostname
if (self.uri.port) {
if ( !(self.uri.port === 80 && self.uri.protocol === 'http:') &&
!(self.uri.port === 443 && self.uri.protocol === 'https:') )
- self.headers.host += (':'+self.uri.port)
+ self.headers.Host += (':'+self.uri.port)
}
self.setHost = true
}
@@ -210,7 +210,7 @@ Request.prototype.init = function (options) {
self.clientErrorHandler = function (error) {
if (self._aborted) return
- if (self.setHost) delete self.headers.host
+ if (self.setHost) delete self.headers.Host
if (self.req._reusedSocket && error.code === 'ECONNRESET'
&& self.agent.addRequestNoreuse) {
self.agent = { addRequest: self.agent.addRequestNoreuse.bind(self.agent) }
@@ -535,7 +535,7 @@ Request.prototype.start = function () {
return
}
- if (self.setHost) delete self.headers.host
+ if (self.setHost) delete self.headers.Host
if (self.timeout && self.timeoutTimer) {
clearTimeout(self.timeoutTimer)
self.timeoutTimer = null
@@ -587,7 +587,7 @@ Request.prototype.start = function () {
delete self.body
delete self._form
if (self.headers) {
- delete self.headers.host
+ delete self.headers.Host
delete self.headers['content-type']
delete self.headers['content-length']
}
Something went wrong with that request. Please try again.