-
-
Notifications
You must be signed in to change notification settings - Fork 36
Support http2 #36
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.
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
base: master
Are you sure you want to change the base?
Support http2 #36
Changes from 4 commits
3a18e17
61e5115
e8e8cbc
c2806ac
e0f0cc6
70d00de
e6da059
765a024
09e012d
9bb739f
0108d17
395e271
9efda35
97c0d7a
e5b45d4
a18f5a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -174,13 +174,55 @@ describe('typeis.hasBody(req)', function () { | |
| assert.strictEqual(typeis.hasBody(req), true) | ||
| }) | ||
| }) | ||
|
|
||
| describe('http2 request', function () { | ||
| it('should not indicate body', function () { | ||
| var req = { | ||
| headers: {}, | ||
| stream: { | ||
| _readableState: { | ||
| ended: true | ||
| } | ||
| }, | ||
| httpVersionMajor: 2 | ||
| } | ||
| assert.strictEqual(typeis.hasBody(req), false) | ||
| }) | ||
|
|
||
| it('should indicate body', function () { | ||
| var req = { | ||
| headers: {}, | ||
| stream: { | ||
| _readableState: { | ||
| ended: false | ||
| } | ||
| }, | ||
| httpVersionMajor: 2 | ||
| } | ||
| assert.strictEqual(typeis.hasBody(req), true) | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| function createRequest (type) { | ||
| return { | ||
| headers: { | ||
| 'content-type': type || '', | ||
| 'transfer-encoding': 'chunked' | ||
| if (process.env.HTTP2_TEST) { | ||
| return { | ||
| headers: { | ||
| 'content-type': type || '' | ||
| }, | ||
| stream: { | ||
| _readableState: { | ||
|
||
| ended: false | ||
| } | ||
| }, | ||
| httpVersionMajor: 2 | ||
| } | ||
| } else { | ||
| return { | ||
| headers: { | ||
| 'content-type': type || '', | ||
| 'transfer-encoding': 'chunked' | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some testing seems like this may have an issue. If you add a
req.on('data'listener and read the body, this then returnsfalsefor http/2 buttruefor http/1. The current interface it is expected to be true for both, as hasBody determines if the request has body, regardless of it you happened to have read it already or not.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked and happens an issue you said. I address this issue and add a test.