You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most clients (including curl) and browsers leave out the :80 & :443 port suffixes in the Host header, and include it only when it is neither of the two. Dropping the port prefix for known services is still RFC-compliant; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23
urllib, however, always includes the port and this can cause incompatibilities with other server implementations.
Examples of other projects stripping the port suffix —
I'll close this now. I tried replicating this with a minimal setup, and it works and I see no issue. This must've been injected elsewhere in our stack.
Thanks for responding, and sorry for the trouble @fengmk2!
For anyone else interested, here's a simple echo server that logs request headers —
// Server that listens on 'localhost:80'.
var http = require('http');
http.createServer(function(request,response){
console.log('HEADERS: ', request.headers);
response.writeHead(200);
request.on('data',function(message){
response.write(message);
});
request.on('end',function(){
response.end();
});
}).listen(80);
And a simple request to the echo server —
// Send a request to 'localhost:80' using urllib
var urllib = require('urllib');
urllib.request('http://localhost:80', function (err, data, res) {
if (err) {
throw err; // you need to handle error
}
console.log(res.statusCode);
console.log(res.headers);
// data is Buffer instance
console.log(data.toString());
});
Most clients (including
curl
) and browsers leave out the:80
&:443
port suffixes in theHost
header, and include it only when it is neither of the two. Dropping the port prefix for known services is still RFC-compliant; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23urllib
, however, always includes the port and this can cause incompatibilities with other server implementations.Examples of other projects stripping the port suffix —
request.hostname
, notrequest.headers.host
twilio/twilio-node#151The text was updated successfully, but these errors were encountered: