-
Notifications
You must be signed in to change notification settings - Fork 16
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
Issue with streams? #1
Comments
More details on this: I tried debugging by setting up a simple http2 server that just pipes the input stream to stdout: const http2 = require('http2');
const server = http2.createServer();
server.on('stream', (stream, headers) => {
console.log(headers)
stream.pipe(process.stdout);
stream.respond({
'content-type': 'text/html',
':status': 200
});
stream.end('<h1>Hello World</h1>');
});
server.listen(8080, err => {
console.log('started server on port 8080')
}); This first thing I found out is I needed to remove the After removing that header: If I make a request with a If I make the same request but switching the body to a |
This is surely a bug, I'm looking at fixing it right now |
I just added unit tests for sending a stream, and it seems to work when 'content-length' is set. I'll add tests for when not having 'content-length' set, to ensure chunked stream data can be sent. Small detail, how about adding |
I've fixed the handling of headers with upper-case characters (in http2, they are all lower-case) which probably fixed the 'Content-Type' issue. Please try latest (0.0.9) to see if the problem remains. |
Also, numeric values will be allowed too (as your |
Gotcha. Thanks for getting to this so quick. Love the good work and I'll
give this a shot soon :)
…On Sat, 28 Oct 2017, 11:09 Gustaf Räntilä, ***@***.***> wrote:
Also, numeric values will be allowed too (as your data.length). If
running with TypeScript, it won't be *statically* allowed, but at
run-time it'll be stringified.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABtutBBei7V5jKjKLotFIzxxR3DL26Cjks5sw1HRgaJpZM4QIk4b>
.
|
So, my server definitely now received the right headers: { ':authority': 'localhost:8080',
':path': '/',
':scheme': 'http',
':method': 'POST',
accept: 'application/json, text/*;0.9, */*;q=0.8',
'user-agent': 'fetch-h2/0.0.9 (+https://github.com/grantila/fetch-h2) nodejs/8.8.1 nghttp2/1.25.0 uv/1.15.0',
'content-type': 'application/octet-stream',
'content-length': '4862966',
'custom-header': 'custom value' } however, I'm still not able to log the body contents. On the server. Am I accessing the stream incorrectly on the server? I'm basically just doing: server.on('stream', (stream, headers) => {
console.log(headers)
stream.pipe(process.stdout);
...
}); That seems to only work when the body is not a stream |
That looks right. I added a unit test which sends a stream to the server, which just echoes it back: I'm starting to wonder if there's another problem. I'll add unit tests with large payloads, just to get it covered. |
Does it work if you don't set |
It wasn't an issue with the payload size. I've tried sending a much smaller dataset too, and I'm still running into the same issue. Not setting |
Umm, interesting. I looked at the test case you setup, and noticed you were using |
Alright, that's... Interesting. I just filed a bug upstream because it seems to be issues with the |
Confirmed and with a PR. I'll keep this open until we know in what version this fix is released, after which I'll have to ensure it also works here. |
@grantila Thanks a bunch for following up with this (and glad I could help out, haha) There seem to be quite a few more things that still need to be implemented to get this library to full parity with Lines 176 to 221 in a35903c
I'm super happy to help out with completing this implementation as I plan to use it in production. Do you have a specific thing you'd like for me to focus on? Email me at pranay.gp@gmail.com and we can start a conversation :) |
Already in master :) nodejs/node#16580 |
Fix released in 0.0.11 |
this may not be an issue with the library at all, but, I'm running into an issue with using this when I try to use a stream as my body.
I'm using the resumer package to create a readable stream from file data as so
and then trying to make a fetch:
But this causes the server I'm hitting to respond with a 400 error ('Bad request').
Doing the same thing above, but using
node-fetch
and just usingstream
directly (without wrapping it innew StreamBody(stream)
for thebody
has my server working.Is this a known issue/could you help me debug this? Would really appreciate it :)
The text was updated successfully, but these errors were encountered: