joyent/node — Issue #2198: https with fs.openReadStream hangs
Author: egorFiNE
Created: 2011-11-26 12:47:17+00:00
State: open

## What have I done?

1. Ran this code:

```javascript
fs = require('fs');
https = require('https');

var options = {
key: fs.readFileSync('ssl-insecure.key'),
cert: fs.readFileSync('ssl.crt')
};

// file must be more than 100k; I tested with 620k file
var bigFile = fs.readFileSync('bigfile');
var server = https.createServer(options, function (req, res) {
res.writeHead(200, {
'Content-Length': bigFile.length
});

var stream = fs.createReadStream('bigfile', {});
req.emit('static', stream);
stream.pipe(res);

// the following code works well:
//res.write(bigFile);
//res.end();
});

server.listen(3000);
```

2. Do wget https://host:3000/something

## What have I got

```
float:~ egor$ wget https://somewhere:3000/bigfile
--2011-11-26 14:40:32-- https://somewhere:3000/bigfile
Resolving somewhere... 1.2.3.4
Connecting to somewhere|1.2.3.4|:3000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 653807 (638K)
Saving to: `bigfile.10'

12% [==========> ] 81,920 30.8K/s
```

Stable hang at 81920.

## What have I expected

A download not slower than over regular http.

## Additional info

Using fs.createReadStream is the standard way of serving static files with Express framework.

Ubuntu 11.04, Node 0.6.any; also repeatable on OS X 10.7.2.