Remove excessive copyright/license boilerplate
[platform/upstream/nodejs.git] / test / parallel / test-http-header-read.js
1 var common = require('../common');
2 var assert = require('assert');
3 var http = require('http');
4
5 // Verify that ServerResponse.getHeader() works correctly even after
6 // the response header has been sent. Issue 752 on github.
7
8 var s = http.createServer(function(req, res) {
9   var contentType = 'Content-Type';
10   var plain = 'text/plain';
11   res.setHeader(contentType, plain);
12   assert.ok(!res.headersSent);
13   res.writeHead(200);
14   assert.ok(res.headersSent);
15   res.end('hello world\n');
16   // This checks that after the headers have been sent, getHeader works
17   // and does not throw an exception (Issue 752)
18   assert.doesNotThrow(
19       function() {
20         assert.equal(plain, res.getHeader(contentType));
21       }
22   );
23 });
24
25 s.listen(common.PORT, runTest);
26
27 function runTest() {
28   http.get({ port: common.PORT }, function(response) {
29     response.on('end', function() {
30       s.close();
31     });
32     response.resume();
33   });
34 }