~ubuntu-branches/ubuntu/precise/nodejs/precise

« back to all changes in this revision

Viewing changes to test/simple/test-http-server-multiheaders.js

  • Committer: Bazaar Package Importer
  • Author(s): Jérémy Lal
  • Date: 2010-08-20 11:49:04 UTC
  • mfrom: (7.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100820114904-lz22w6fkth7yh179
Tags: 0.2.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Verify that the HTTP server implementation handles multiple instances
 
2
// of the same header as per RFC2616: joining the handful of fields by ', '
 
3
// that support it, and dropping duplicates for other fields.
 
4
 
 
5
common = require("../common");
 
6
assert = common.assert
 
7
var http = require('http');
 
8
 
 
9
var srv = http.createServer(function(req, res) {
 
10
  assert.equal(req.headers.accept, 'abc, def, ghijklmnopqrst');
 
11
  assert.equal(req.headers.host, 'foo');
 
12
  assert.equal(req.headers['x-foo'], 'bingo');
 
13
  assert.equal(req.headers['x-bar'], 'banjo, bango');
 
14
 
 
15
  res.writeHead(200, {'Content-Type' : 'text/plain'});
 
16
  res.end('EOF');
 
17
 
 
18
  srv.close();
 
19
});
 
20
 
 
21
srv.listen(common.PORT, function () {
 
22
  var hc = http.createClient(common.PORT, 'localhost');
 
23
  var hr = hc.request('/',
 
24
    [
 
25
      ['accept', 'abc'],
 
26
      ['accept', 'def'],
 
27
      ['Accept', 'ghijklmnopqrst'],
 
28
      ['host', 'foo'],
 
29
      ['Host', 'bar'],
 
30
      ['hOst', 'baz'],
 
31
      ['x-foo', 'bingo'],
 
32
      ['x-bar', 'banjo'],
 
33
      ['x-bar', 'bango']
 
34
    ]
 
35
  );
 
36
  hr.end();
 
37
});