GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http2: fix endless loop when write an empty string by XadillaX · Pull Request #18673 · nodejs/node

http2: fix endless loop when write an empty string #18673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
XadillaX wants to merge 2 commits into nodejs:master from XadillaX:fix-18169

Uh oh!

There was an error while loading. Please reload this page.

Closed

http2: fix endless loop when write an empty string #18673

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
5ab3255
http2: fix endless loop when write an empty string
XadillaX Feb 9, 2018
83fb36a
add test cases
XadillaX Feb 11, 2018
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

10 changes: 10 additions & 0 deletions 10 lib/internal/http2/core.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1622,6 +1622,11 @@ class Http2Stream extends Duplex {
if (!this.headersSent)
this[kProceed]();

if (!data.length) {
cb();
return;
}

const handle = this[kHandle];
const req = new WriteWrap();
req.stream = this[kID];
Expand Down Expand Up @@ -1659,6 +1664,11 @@ class Http2Stream extends Duplex {
if (!this.headersSent)
this[kProceed]();

if (!data.length) {
cb();
return;
}

const handle = this[kHandle];
const req = new WriteWrap();
req.stream = this[kID];
Expand Down
48 changes: 48 additions & 0 deletions 48 test/parallel/test-http2-client-write-empty-string.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';

const assert = require('assert');
const http2 = require('http2');

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const server = http2.createServer();
server.on('stream', common.mustCall((stream, headers, flags) => {
stream.respond({ 'content-type': 'text/html' });

let data = '';
stream.on('data', common.mustNotCall((chunk) => {
data += chunk.toString();
}));
stream.on('end', common.mustCall(() => {
stream.end(`"${data}"`);
}));
}));

server.listen(0, common.mustCall(() => {
const port = server.address().port;
const client = http2.connect(`http://localhost:${port}`);

const req = client.request({
':method': 'POST',
':path': '/'
});

req.on('response', common.mustCall((headers) => {
assert.strictEqual(headers[':status'], 200);
assert.strictEqual(headers['content-type'], 'text/html');
}));

let data = '';
req.setEncoding('utf8');
req.on('data', common.mustCallAtLeast((d) => data += d));
req.on('end', common.mustCall(() => {
assert.strictEqual(data, '""');
server.close();
client.close();
}));

req.write('');
req.end();
}));
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.