Permalink
Browse files

add port to host header

  • Loading branch information...
ma2rten committed Jul 20, 2011
1 parent bce2924 commit 7b602dfa5cd3b719e1600a6953cb842f7f8849c5
Showing with 21 additions and 19 deletions.
  1. +21 −19 lib/node.io/request.js
View
@@ -233,25 +233,6 @@ Job.prototype.doRequest = function (method, resource, body, headers, callback, p
//Parse the URL into parts
url = urlparse(resource, false),
- //Determine the port
- port = url.port;
- if (!port) {
- switch (url.protocol) {
- case 'http:':
- port = 80;
- break;
- case 'https:':
- port = 443;
- secure = true;
- break;
- case 'ftp:':
- port = 21;
- break;
- default:
- port = 80;
- }
- }
-
//Get the request path
path = url.pathname || '/';
if (url.search) {
@@ -288,6 +269,27 @@ Job.prototype.doRequest = function (method, resource, body, headers, callback, p
headers['Content-Length'] = body.length;
}
+ //Determine the port and add it to the host header
+ port = url.port;
+ if (!port) {
+ switch (url.protocol) {
+ case 'http:':
+ port = 80;
+ break;
+ case 'https:':
+ port = 443;
+ secure = true;
+ break;
+ case 'ftp:':
+ port = 21;
+ break;
+ default:
+ port = 80;
+ }
+ } else {
+ headers.host += ':' + port;
+ }
+
method = method.toUpperCase();
//Debug request headers

0 comments on commit 7b602df

Please sign in to comment.