🐞BUG: not working with 'chunked' data! (fix inside)
- Dominant language
- JavaScript
- Stars
- 7.9k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
test with http://emojitracker.com/
It sends 'chunked' data with headers: ```"transfer-encoding":"chunked"```
To get this working we need three things:
1) catch the 'transfer-encoding' === 'chunked'
2) don't .push to resData but send to user
3) don't close the socket but write to it
You need to add code to catch chunked data :
from
```
...
res.on("data", function (chunk) {
resData.push(chunk);
}
...
```
to
```
...
res.on("data", function (chunk) {
if (resHeader['transfer-encoding'] === 'chunked') {
processResponse([chunk], {'chunked': true});
} else {
resData.push(chunk);
}
}
...
```
Then you need to move whole async code
```
...
var serverResData;
async.series([
//ungzip server res
function (callback) {
...
```
to the function
```
function processResponse(resData, chunked) {
var serverResData;
async.series([
//ungzip server res
function (callback) {
...
```
notice it takes resData as an argument!
and replace the code there for response not to close the socket
```
//send response
}, function (callback) {
if (global._throttle) {
console.log(21);
var thrStream = new Stream();
var readable = thrStream.pipe(global._throttle.throttle());
readable.pipe(userRes);
thrStream.emit("data", serverResData);
thrStream.emit("end");
callback();
} else {
userRes.end(serverResData);
callback();
}
```
to
```
//send response
}, function (callback) {
if (global._throttle) {
console.log(21);
var thrStream = new Stream();
var readable = thrStream.pipe(global._throttle.throttle());
readable.pipe(userRes);
thrStream.emit("data", serverResData);
thrStream.emit("end");
callback();
} else {
if (chunked) {
userRes.write(serverResData);
} else {
userRes.end(serverResData);
}
callback();
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the response handler containing res.on("data"), resData, processResponse, and the async.series response flow. Check the behavior with emojitracker.com or another transfer-encoding: chunked response, then verify that chunked data is forwarded incrementally without closing the socket while non-chunked responses retain their existing completion behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100