Skip to content

http2 support #1193

Closed
Closed

Description

@budarin

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

Activity

  1. likegun commented on May 17, 2018

    @likegun
    Contributor

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

  2. budarin commented on May 17, 2018

    @budarin
    Author

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

  3. cupcakearmy commented on May 30, 2018

    @cupcakearmy

    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?

  4. fl0w commented on May 30, 2018

    @fl0w
    Contributor

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

  5. budarin commented on May 30, 2018

    @budarin
    Author

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

  6. fl0w commented on May 30, 2018

    @fl0w
    Contributor

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

  7. budarin commented on May 30, 2018

    @budarin
    Author

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

  8. fl0w commented on May 30, 2018

    @fl0w
    Contributor

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

  9. budarin commented on May 30, 2018

    @budarin
    Author

    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?

  10. alexander-akait commented on Jul 30, 2019

    @alexander-akait

    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

  11. wood1986 commented on Aug 29, 2019

    @wood1986

    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);
  12. changed the title [-]http2 is out in node. [/-] [+]http2 push support[/+] on Apr 28, 2020
  13. changed the title [-]http2 push support[/-] [+]http2 push stream support[/+] on Apr 28, 2020
  14. changed the title [-]http2 push stream support[/-] [+]http2 support[/+] on Apr 28, 2020
  15. jonathanong commented on Apr 28, 2020

    @jonathanong
    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

  16. niftylettuce commented on Aug 22, 2020

    @niftylettuce
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions