This commit is contained in:
Ciro Spaciari
2025-05-30 03:40:28 -07:00
parent c54a739d28
commit fcef720d48
2 changed files with 9 additions and 3 deletions

View File

@@ -1787,7 +1787,6 @@ pub const H2FrameParser = struct {
}
fn checkIfShouldAutoFlush(this: *H2FrameParser) void {
log("writeBuffer.len {} {}", .{ this.writeBuffer.slice()[this.writeBufferOffset..].len, this.isServer });
const corkedBuffer = if (CORKED_H2) |corked| if (@intFromPtr(corked) == @intFromPtr(this)) CORK_OFFSET else 0 else 0;
if (corkedBuffer > 0) {
this.registerAutoFlush();
@@ -1994,6 +1993,7 @@ pub const H2FrameParser = struct {
this.sendGoAway(frame.streamIdentifier, ErrorCode.FRAME_SIZE_ERROR, "Invalid dataframe frame size", this.lastStreamID, true);
return data.len;
}
const end: usize = @min(@as(usize, @intCast(this.remainingLength)), data.len);
var payload = data[0..end];
@@ -2026,7 +2026,7 @@ pub const H2FrameParser = struct {
payload = payload[0..@min(@as(usize, @intCast(data_needed)), payload.len)];
const chunk = this.handlers.binary_type.toJS(payload, this.handlers.globalObject);
// its fine to truncate because is not possible to receive more data than u32 here, usize is only because of slices in size
this.ajustWindowSize(stream, frame.length);
this.ajustWindowSize(stream, @truncate(payload.len));
this.dispatchWithExtra(.onStreamData, stream.getIdentifier(), chunk);
emitted = true;
} else {

View File

@@ -16,21 +16,27 @@ tmpdir.refresh();
const loc = fixtures.path('person-large.jpg');
const fn = tmpdir.resolve('person-large.jpg');
const server = http2.createServer();
const server = http2.createServer({
// initialWindowSize: 655360,
});
server.on('stream', common.mustCall((stream) => {
console.log("stream");
const dest = stream.pipe(fs.createWriteStream(fn));
stream.on('end', common.mustCall(() => {
console.log("end");
stream.respond();
stream.end();
}));
dest.on('finish', common.mustCall(() => {
console.log("finish");
assert.strictEqual(fs.readFileSync(fn).length,
fs.readFileSync(loc).length);
}));
}));
server.listen(common.PIPE, common.mustCall(() => {
const client = http2.connect('http://localhost', {
createConnection(url) {