Created
February 2, 2012 15:03
-
-
Save OrangeDog/1723858 to your computer and use it in GitHub Desktop.
Attachments for joyent/node issue: Large file downloads failing in 0.6.9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Node server (8301) to curl client (44366) | |
HTTP/1.1 200 OK | |
Content-Type: application/zip | |
Content-Disposition: attachment; filename="bigFile.zip" | |
Content-Length: 10001676 | |
Last-Modified: Thu, 02 Feb 2012 11:50:07 UTC | |
Connection: keep-alive | |
PK....... etc. | |
Premature end of stream has the following packets: | |
5305 123.278226 TCP 8301 > 44366 [ACK] Seq=6345390 Ack=387 Win=6912 Len=1448 TSV=1125029462 TSER=1125082578 | |
5306 123.278229 TCP 8301 > 44366 [FIN, PSH, ACK] Seq=6346838 Ack=387 Win=6912 Len=1448 TSV=1125029462 TSER=1125082578 | |
5307 123.317119 TCP 44366 > 8301 [ACK] Seq=387 Ack=6348287 Win=6784 Len=0 TSV=1125082588 TSER=1125029462 | |
5350 126.289118 TCP 44366 > 8301 [FIN, ACK] Seq=387 Ack=6348287 Win=64896 Len=0 TSV=1125083330 TSER=1125029462 | |
5351 126.289137 TCP 8301 > 44366 [ACK] Seq=6348287 Ack=388 Win=6912 Len=0 TSV=1125030215 TSER=1125083330 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), http = require('http'); | |
http.createServer(function(request, response) { | |
var path = 'bigFile.zip'; | |
var stats = fs.statSync(path); | |
var originalWrite = response.write.bind(response); | |
var originalEnd = response.end.bind(response); | |
response.write = function(data, /*optional*/ encoding) { | |
originalWrite(data, encoding); | |
request.totalLength += typeof data === 'string' ? Buffer.byteLength(data) : data.length; | |
}; | |
response.end = function(/*optional*/ data, encoding) { | |
originalEnd(data, encoding); | |
if (data) { | |
request.totalLength += typeof data === 'string' ? Buffer.byteLength(data) : data.length; | |
} | |
}; | |
response.setHeader('Content-Type', 'application/zip'); | |
response.setHeader('Content-Disposition', 'attachment; filename="bigFile.zip"'); | |
response.setHeader('Content-Length', stats.size); | |
var input = fs.createReadStream(path); | |
input.pipe(response); | |
}).listen(8080); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Node server (8301) to curl client (45851) | |
HTTP/1.1 200 OK | |
Content-Type: application/zip | |
Content-Disposition: attachment; filename="bigFile.zip" | |
Content-Length: 10001676 | |
Last-Modified: Thu, 02 Feb 2012 11:50:07 UTC | |
Connection: keep-alive | |
PK....... etc. | |
End of stream has the following packets: | |
8296 195.115593 TCP 45851 > 8301 [ACK] Seq=387 Ack=10001930 Win=12032 Len=0 TSV=1124431200 TSER=1124378069 | |
8335 195.996463 TCP [TCP Window Update] 45851 > 8301 [ACK] Seq=387 Ack=10001930 Win=28928 Len=0 TSV=1124431420 TSER=1124378069 | |
8336 195.999474 TCP [TCP Window Update] 45851 > 8301 [ACK] Seq=387 Ack=10001930 Win=60416 Len=0 TSV=1124431420 TSER=1124378069 | |
8397 198.020599 TCP 45851 > 8301 [FIN, ACK] Seq=387 Ack=10001930 Win=64896 Len=0 TSV=1124431925 TSER=1124378069 | |
8398 198.020909 TCP 8301 > 45851 [FIN, ACK] Seq=10001930 Ack=388 Win=6912 Len=0 TSV=1124378805 TSER=1124431925 | |
8399 198.021189 TCP 45851 > 8301 [ACK] Seq=388 Ack=10001931 Win=64896 Len=0 TSV=1124431925 TSER=1124378805 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment