-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: don't confuse automatic headers for others #828
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var http = require('http'); | ||
|
||
var server = http.createServer(function(req, res) { | ||
res.setHeader('X-Date', 'foo'); | ||
res.setHeader('X-Connection', 'bar'); | ||
res.setHeader('X-Transfer-Encoding', 'baz'); | ||
res.end(); | ||
}); | ||
server.listen(common.PORT); | ||
|
||
server.on('listening', function() { | ||
var agent = new http.Agent({ port: common.PORT, maxSockets: 1 }); | ||
http.get({ | ||
port: common.PORT, | ||
path: '/hello', | ||
agent: agent | ||
}, function(res) { | ||
assert.equal(res.statusCode, 200); | ||
assert.equal(res.headers['x-date'], 'foo'); | ||
assert.equal(res.headers['x-connection'], 'bar'); | ||
assert.equal(res.headers['x-transfer-encoding'], 'baz'); | ||
assert(res.headers['date']); | ||
assert.equal(res.headers['connection'], 'keep-alive'); | ||
assert.equal(res.headers['transfer-encoding'], 'chunked'); | ||
server.close(); | ||
agent.destroy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,8 @@ var proxy = net.createServer(function(clientSocket) { | |
// Verify the CONNECT request | ||
assert.equal('CONNECT localhost:' + common.PORT + ' HTTP/1.1\r\n' + | ||
'Proxy-Connections: keep-alive\r\n' + | ||
'Host: localhost:' + proxyPort + '\r\n\r\n', | ||
'Host: localhost:' + proxyPort + '\r\n' + | ||
'Connection: close\r\n\r\n', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this related to the fix? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'd say that if you're going to do that you should remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, but that is not really relevant to this change. The |
||
chunk); | ||
|
||
console.log('PROXY: got CONNECT request'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this left out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, nmind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a possible bug also. Maybe this regexp: