~ubuntu-branches/ubuntu/natty/nodejs/natty

« back to all changes in this revision

Viewing changes to test/simple/test-zerolengthbufferbug.js

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard, Jérémy Lal, Jonas Smedegaard
  • Date: 2011-02-07 23:39:40 UTC
  • mfrom: (7.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110207233940-ctxh80ux4u7xfybh
Tags: 0.2.6-4
[ Jérémy Lal ]
* Disable simple/test-buffer Buffer.unpack test that fails on ARM.
  The pack/unpack functions are deprecated, and not documented.

[ Jonas Smedegaard ]
* Drop done items from TODO.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Serving up a zero-length buffer should work.
 
2
 
 
3
var common = require("../common");
 
4
var assert = common.assert;
 
5
var http = require('http');
 
6
 
 
7
var server = http.createServer(function (req, res) {
 
8
  var buffer = new Buffer(0);
 
9
  res.writeHead(200, {'Content-Type': 'text/html',
 
10
                      'Content-Length': buffer.length});
 
11
  res.end(buffer);
 
12
});
 
13
 
 
14
var gotResponse = false;
 
15
var resBodySize = 0;
 
16
 
 
17
server.listen(common.PORT, function () {
 
18
  var client = http.createClient(common.PORT);
 
19
  
 
20
  var req = client.request('GET', '/');
 
21
  req.end();
 
22
 
 
23
  req.on('response', function (res) {
 
24
    gotResponse = true;
 
25
 
 
26
    res.on('data', function (d) {
 
27
      resBodySize += d.length;
 
28
    });
 
29
 
 
30
    res.on('end', function (d) {
 
31
      server.close();
 
32
    });
 
33
  });
 
34
});
 
35
 
 
36
process.on('exit', function () {
 
37
  assert.ok(gotResponse);
 
38
  assert.equal(0, resBodySize);
 
39
});
 
40
 
 
41