-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a getAllHeaders function to the http module
Users should not have to access private attributes like res._headers in order to get all the headers in a request. Define a method getAllHeaders to return an object which is a copy of re._headers Fixes issue #3992
- Loading branch information
1 parent
b4a670a
commit 427fd00
Showing
4 changed files
with
40 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var http = require('http'); | ||
|
||
// Verify that ServerResponse.getHeader() works correctly even after | ||
// the response header has been sent. Issue 752 on github. | ||
|
||
var rando = Math.random(); | ||
var expected = util._extend({}, { | ||
'X-Random-Thing': rando, | ||
}); | ||
var server = http.createServer(function(req, res) { | ||
res.setHeader('X-Random-Thing', rando); | ||
headers = res.getAllHeaders(); | ||
res.end('hello'); | ||
assert.strictEqual(res.getAllHeaders(), null); | ||
}); | ||
server.listen(common.PORT, function() { | ||
http.get({port: common.PORT}, function(resp) { | ||
assert.deepEqual(response.headers, expected); | ||
server.close(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.