doc: fix bug in readable.unshift
code example
PR-URL: https://github.com/nodejs/node/pull/41944 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
d17be0fbe5
commit
ee38bbd4cf
@ -1586,7 +1586,7 @@ function parseHeader(stream, callback) {
|
|||||||
let chunk;
|
let chunk;
|
||||||
while (null !== (chunk = stream.read())) {
|
while (null !== (chunk = stream.read())) {
|
||||||
const str = decoder.write(chunk);
|
const str = decoder.write(chunk);
|
||||||
if (str.match(/\n\n/)) {
|
if (str.includes('\n\n')) {
|
||||||
// Found the header boundary.
|
// Found the header boundary.
|
||||||
const split = str.split(/\n\n/);
|
const split = str.split(/\n\n/);
|
||||||
header += split.shift();
|
header += split.shift();
|
||||||
@ -1599,12 +1599,12 @@ function parseHeader(stream, callback) {
|
|||||||
stream.unshift(buf);
|
stream.unshift(buf);
|
||||||
// Now the body of the message can be read from the stream.
|
// Now the body of the message can be read from the stream.
|
||||||
callback(null, header, stream);
|
callback(null, header, stream);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
// Still reading the header.
|
// Still reading the header.
|
||||||
header += str;
|
header += str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user