Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
Handle hosts with ports
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Oct 5, 2010
1 parent ce357ab commit a743858
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/utils/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ function fetch (remote, local, headers, cb) {
if (!cb) cb = headers, headers = {}
log.info(remote, "fetch")
log.verbose(local, "fetch to")
headers.host = url.parse(remote).hostname
var r = url.parse(remote)
headers.host = r.hostname + (r.port ? ":"+r.port : "")
log.verbose(headers, "request headers")
log.verbose(remote, "remote url")
fs.open(local, consts.O_CREAT | consts.O_WRONLY | consts.O_TRUNC, 0755,
function (er, fd) {
if (er) return cb(new Error(
Expand All @@ -39,7 +42,7 @@ function fetchAndWrite (remote, fd, headers, maxRedirects, redirects, cb) {
if (!cb) cb = maxRedirects, maxRedirects = 10
if (!cb) throw new Error("No callback provided")
remote = url.parse(remote)
set(headers, "host", remote.hostname)
set(headers, "host", remote.hostname + (remote.port ? ":"+remote.port:""))
remote.path = remote.pathname+(remote.search||"")+(remote.hash||"")
var proxyConfig = npm.config.get("proxy")
if (proxyConfig) {
Expand Down

0 comments on commit a743858

Please sign in to comment.