-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Support http2 #36
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: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At this point if we are depending on Node.js internals for the state, we need to test against the actual Node.js implementation instead of a simple mock. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either that or there is specific documentation in Node.js documenting this exact behavior, though I didn't see that anywhere. Without one of these we won't know when Node.js changes it's behavior as our tests won't fail. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will fix tests tomorrow. |
||
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 returnsfalse
for http/2 buttrue
for 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.