Skip to content
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

http2 support #1193

Closed
budarin opened this issue May 16, 2018 · 13 comments
Closed

http2 support #1193

budarin opened this issue May 16, 2018 · 13 comments
Labels

Comments

@budarin
Copy link

budarin commented May 16, 2018

http2 is out in node 10.0.0.
will http 2 be supported by the library?

@likegun
Copy link
Contributor

likegun commented May 17, 2018

@budarin You can use require('http2').createSecureServer(cert, new Koa().callback()).listen() to use http2 which answered by fl0w in this issue

@budarin
Copy link
Author

budarin commented May 17, 2018

I am not about creating and starting the server - it is simple, I am about pushing resources, methods signatures and so

@cupcakearmy
Copy link

cupcakearmy commented May 30, 2018

While

require('http2').createSecureServer(cert, new Koa().callback()).listen()

is really neat and simple, I believe that something along the lines of

new Koa({
    http2: {
        cert: ...,
        key: ...,
        enabled: true | false    // Optional for debugging
    }
})

could be very helpful and really not a big addition in terms of codebase and complexity.

It's the same reason why we don't use

require('http').createServer(new Koa().callback()).listen()

Any thoughts on the matter?

@fl0w
Copy link
Contributor

fl0w commented May 30, 2018

@cupcakearmy That proposal was turned down in #1063, I added a summary in this comment

@budarin
Copy link
Author

budarin commented May 30, 2018

if I have to use callback syntax - then why do I need koa ???

@fl0w
Copy link
Contributor

fl0w commented May 30, 2018

@budarin Because that's the design of http. Koa's essentially just a "sugarized" requestListener.

@budarin
Copy link
Author

budarin commented May 30, 2018

I am about somthing like a push method in express ...
Using http2 like a usual https - what is a profit?

@fl0w
Copy link
Contributor

fl0w commented May 30, 2018

@budarin Nobody said not to expand Koa support for HTTP/2, let's wait and see what happens.

@budarin
Copy link
Author

budarin commented May 30, 2018

what year can we see it? :)
and one more question: will it be using compatibility API like it does at now or will use native HTTP/2 stream API?

@fl0w fl0w added the http/2 label Sep 24, 2018
@alexander-akait
Copy link

We think about migration from express to koa in webpack-dev-server, it is only one blocker for us, can't find documentation how koa works with http2 and examples

@wood1986
Copy link

Hey @evilebottnawi, FYI I can get koa work with http2. This is the code that I am using

const http = require('http');
const http2 = require('http2');
const Koa = require('koa');
const app = new Koa();

// response
app.use(ctx => {
  ctx.body = 'Hello Koa';
});

http.createServer(app.callback()).listen(80);

http2.createSecureServer({
  "key": certificate,
  "cert": certificate
}, app.callback()).listen(443);

@jonathanong jonathanong changed the title http2 is out in node. http2 push support Apr 28, 2020
@jonathanong jonathanong changed the title http2 push support http2 push stream support Apr 28, 2020
@jonathanong jonathanong changed the title http2 push stream support http2 support Apr 28, 2020
@jonathanong
Copy link
Member

i've looked at this a long time ago, and adding push support was complicated and did not provide much benefit. koa would basically just set headers in the stream, but you'd still need to pipe data to the stream yourself.

this might be better as a framework using koa than supported in koa itself

let us know if you have any API recommendations

@niftylettuce
Copy link
Contributor

HTTP/2 already works with Koa.

See https://github.com/ladjs/web/blob/master/index.js for an example (note the lines are currently commented out because there is a core bug in Node with HTTP/2 XHR requests; they do not work). See https://www.theregister.com/2020/08/18/nodejs_chromium_patch/.

Ref: nodejs/node#33875 and <https://bugs.chromium.org/p/chromium/issues/detail?id=1045328#c46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants