You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@jasnell or anybody else that would care to comment. I'm wondering a couple of things regarding HTTP/2 push streams:
If I understand things correctly, push streams are intended to proactively serve resources that are needed to get a page on screen as quickly as possible. Basically compressing the fetch-parse-fetch-parse loop.
So with that in mind, I though of this: index.htm needs a few resources, css and js. The js file needs a few resources, say some json data.
I want to push resources to a document served by a push stream.
So here is what I tried:
//server = http2.createSecureServer(); init code removed for brevityserver.addListener('stream',function(stream,headers){letresourcePath=path.join(serverRootPath,headers[HTTP2_HEADER_PATH]);stream.respondWithFile(resourcePath,{'content-type': mimeTypes.get(resourcePath.match(mimeRegExp)[0]),});});
Yay I have a static file server, except no push. So I modify to this:
The train derails here. I get an error stating an invalid argument for the nested push stream, and the json file is served through another get request.
What am I missing? The nested pushstream callback gets an error instead of a stream, but I don't understand why.
On a more design level curiosity, why was the stream.pushStream() function designed with a callback, and not as a promise? Given that pushStream generates a request Promise... or am I conflating two different uses of Promise?
The text was updated successfully, but these errors were encountered:
robbie-mac
changed the title
Are nested or recursive HTTP/2 push streams posible?
Are nested or recursive HTTP/2 push streams possible?
Mar 1, 2018
@jasnell or anybody else that would care to comment. I'm wondering a couple of things regarding HTTP/2 push streams:
If I understand things correctly, push streams are intended to proactively serve resources that are needed to get a page on screen as quickly as possible. Basically compressing the fetch-parse-fetch-parse loop.
So with that in mind, I though of this: index.htm needs a few resources, css and js. The js file needs a few resources, say some json data.
I want to push resources to a document served by a push stream.
So here is what I tried:
Yay I have a static file server, except no push. So I modify to this:
Yay, I have a working push stream. Then I add a push stream inside of the push stream callback
The train derails here. I get an error stating an invalid argument for the nested push stream, and the json file is served through another get request.
What am I missing? The nested pushstream callback gets an error instead of a stream, but I don't understand why.
On a more design level curiosity, why was the stream.pushStream() function designed with a callback, and not as a promise? Given that pushStream generates a request Promise... or am I conflating two different uses of Promise?
The text was updated successfully, but these errors were encountered: