1 // Copyright Joyent, Inc. and other Node contributors.
3 // Permission is hereby granted, free of charge, to any person obtaining a
4 // copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to permit
8 // persons to whom the Software is furnished to do so, subject to the
9 // following conditions:
11 // The above copyright notice and this permission notice shall be included
12 // in all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
17 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 // USE OR OTHER DEALINGS IN THE SOFTWARE.
22 var common = require('../common');
23 var assert = require('assert');
25 var http = require('http');
27 http.createServer(function(req, res) {
29 var expectRawHeaders = [
31 'localhost:' + common.PORT,
40 host: 'localhost:' + common.PORT,
41 'transfer-encoding': 'CHUNKED',
46 var expectRawTrailers = [
57 var expectTrailers = { 'x-bar': 'yOyOyOy, OyOyOyO, yOyOyOy, OyOyOyO' };
59 assert.deepEqual(req.rawHeaders, expectRawHeaders);
60 assert.deepEqual(req.headers, expectHeaders);
62 req.on('end', function() {
63 assert.deepEqual(req.rawTrailers, expectRawTrailers);
64 assert.deepEqual(req.trailers, expectTrailers);
75 }).listen(common.PORT, function() {
76 var expectRawHeaders = [
78 'Tue, 06 Aug 2013 01:31:54 GMT',
84 var req = http.request({ port: common.PORT, path: '/' });
91 req.setHeader('transfer-ENCODING', 'CHUNKED');
92 req.setHeader('x-BaR', 'yoyoyo');
94 req.on('response', function(res) {
95 var expectRawHeaders = [
103 var expectHeaders = {
106 'transfer-encoding': 'chunked'
108 res.rawHeaders[1] = null;
109 res.headers.date = null;
110 assert.deepEqual(res.rawHeaders, expectRawHeaders);
111 assert.deepEqual(res.headers, expectHeaders);
112 res.on('end', function() {
113 var expectRawTrailers = [
123 var expectTrailers = { 'x-foo': 'xOxOxOx, OxOxOxO, xOxOxOx, OxOxOxO' };
125 assert.deepEqual(res.rawTrailers, expectRawTrailers);
126 assert.deepEqual(res.trailers, expectTrailers);