2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2010-06-21 13:53:17 -05:00
|
|
|
// Verify that the HTTP server implementation handles multiple instances
|
|
|
|
// of the same header as per RFC2616: joining the handful of fields by ', '
|
|
|
|
// that support it, and dropping duplicates for other fields.
|
|
|
|
|
2010-12-04 15:20:34 -08:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2010-06-21 13:53:17 -05:00
|
|
|
var http = require('http');
|
|
|
|
|
|
|
|
var srv = http.createServer(function(req, res) {
|
|
|
|
assert.equal(req.headers.accept, 'abc, def, ghijklmnopqrst');
|
|
|
|
assert.equal(req.headers.host, 'foo');
|
2012-02-15 00:20:54 +01:00
|
|
|
assert.equal(req.headers['www-authenticate'], 'foo, bar, baz');
|
2012-09-24 11:18:05 +03:00
|
|
|
assert.equal(req.headers['proxy-authenticate'], 'foo, bar, baz');
|
2010-06-21 13:53:17 -05:00
|
|
|
assert.equal(req.headers['x-foo'], 'bingo');
|
|
|
|
assert.equal(req.headers['x-bar'], 'banjo, bango');
|
2012-02-16 10:42:13 +01:00
|
|
|
assert.equal(req.headers['sec-websocket-protocol'], 'chat, share');
|
|
|
|
assert.equal(req.headers['sec-websocket-extensions'], 'foo; 1, bar; 2, baz');
|
2010-06-21 13:53:17 -05:00
|
|
|
|
|
|
|
res.writeHead(200, {'Content-Type' : 'text/plain'});
|
|
|
|
res.end('EOF');
|
|
|
|
|
|
|
|
srv.close();
|
|
|
|
});
|
|
|
|
|
2010-12-06 01:33:52 +03:00
|
|
|
srv.listen(common.PORT, function() {
|
2011-08-14 15:02:14 +09:00
|
|
|
http.get({
|
|
|
|
host: 'localhost',
|
|
|
|
port: common.PORT,
|
|
|
|
path: '/',
|
|
|
|
headers: [
|
|
|
|
['accept', 'abc'],
|
|
|
|
['accept', 'def'],
|
|
|
|
['Accept', 'ghijklmnopqrst'],
|
|
|
|
['host', 'foo'],
|
|
|
|
['Host', 'bar'],
|
|
|
|
['hOst', 'baz'],
|
2012-02-15 00:20:54 +01:00
|
|
|
['www-authenticate', 'foo'],
|
|
|
|
['WWW-Authenticate', 'bar'],
|
|
|
|
['WWW-AUTHENTICATE', 'baz'],
|
2015-06-28 17:42:35 +02:00
|
|
|
['proxy-authenticate', 'foo'],
|
|
|
|
['Proxy-Authenticate', 'bar'],
|
|
|
|
['PROXY-AUTHENTICATE', 'baz'],
|
2011-08-14 15:02:14 +09:00
|
|
|
['x-foo', 'bingo'],
|
|
|
|
['x-bar', 'banjo'],
|
2012-02-16 10:42:13 +01:00
|
|
|
['x-bar', 'bango'],
|
|
|
|
['sec-websocket-protocol', 'chat'],
|
|
|
|
['sec-websocket-protocol', 'share'],
|
|
|
|
['sec-websocket-extensions', 'foo; 1'],
|
|
|
|
['sec-websocket-extensions', 'bar; 2'],
|
|
|
|
['sec-websocket-extensions', 'baz']
|
2011-08-14 15:02:14 +09:00
|
|
|
]
|
|
|
|
});
|
2010-06-21 13:53:17 -05:00
|
|
|
});
|