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

HTTP 2 support #2364

Closed
designfrontier opened this issue Sep 18, 2014 · 15 comments
Closed

HTTP 2 support #2364

designfrontier opened this issue Sep 18, 2014 · 15 comments
Labels

Comments

@designfrontier
Copy link

Would be nice if Express had http 2 support on the roadmap, now that all major browsers support it in their current versions. So I am tossing it in here.

@jamlfy
Copy link

jamlfy commented Sep 18, 2014

SPDY ??

@designfrontier
Copy link
Author

Yes

@Floby
Copy link

Floby commented Sep 18, 2014

I was under the impression that you can already do that with

http2.createServer(app)

and

spdy.createServer(app)

@Twipped
Copy link

Twipped commented Sep 18, 2014

@Floby you mean with the spdy and http2 packages, yes? There's been no addition to node itself to support those.

I imagine that's why it's not officially on express' roadmap.

@Floby
Copy link

Floby commented Sep 18, 2014

Well I would guess that spdy is definitely off the roadmap, spdy being an experimental protocol.

http2 is most probably getting standardized one day. I the meantime, it is (almost) easily implemented in userland with the http2 module which uses a signature similar to the core http/https modules

server push is a method of the http2 response object and I would assume express passes it on transparently.

@dougwilson
Copy link
Contributor

Express has nothing to do with the underlying HTTP protocol version. It already supports HTTP2. Here is an example with the http2 package:

var express = require('express')
var app = express()

app.get('/', function (req, res) {
  res.send('hello, http2!')
})

var options = {
  key: fs.readFileSync('./example/localhost.key'),
  cert: fs.readFileSync('./example/localhost.crt')
};

require('http2').createServer(options, app).listen(8080);

@jamlfy
Copy link

jamlfy commented Feb 10, 2015

@dougwilson
Copy link
Contributor

@alejonext I'm not sure I understand your comment--Express has supported HTTP2/SPDY for a long time.

@jamlfy
Copy link

jamlfy commented Feb 10, 2015

Ha! ok @dougwilson

@techsin
Copy link

techsin commented Feb 22, 2015

Upon reading http2 docs im under impression that you need to write code for server push both on client side and server... is this true? And isnt server push the greatest benefit, to be able send alresources required together and avoid separate requests.

@dougwilson
Copy link
Contributor

This is absolutely true, though I think you can use a module like https://github.com/jshttp/spdy-push ? I'm not that familiar, but Express does not have any knowledge of the underlying protocol version (or even the socket), since at it's core, all Express is is a function you pass as the handler to .createServer.

You can always extend your Express like

var express = require('express')
var app = express()

express.response.push = /* define some method that will become res.push() in your app */

@designfrontier
Copy link
Author

I agree with what @dougwilson says above and where this conversation ended up. http2/spdy should be implemented at a lower level then express and be pretty much transparent to express itself.

@techsin

@jinjor
Copy link

jinjor commented Feb 25, 2015

Does this code still work?

var express = require('express')
var app = express()

app.get('/', function (req, res) {
  res.send('hello, http2!')
})

var options = {
  key: fs.readFileSync('./example/localhost.key'),
  cert: fs.readFileSync('./example/localhost.crt')
};

require('http2').createServer(options, app).listen(8080);

I tried the same thing with newest versions and got an error.
Which library's issue is this?

_stream_readable.js:505
    dest.end();
         ^
TypeError: undefined is not a function
    at Stream.onend (_stream_readable.js:505:10)
    at Stream.g (events.js:199:16)
    at Stream.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11)

Node: v0.12.0
node-http2: v3.2.0
express: v4.11.2

@dougwilson
Copy link
Contributor

File an issue at https://github.com/molnarg/node-http2

@expressjs expressjs locked and limited conversation to collaborators Feb 25, 2015
@dougwilson
Copy link
Contributor

For people still dropping by here, use https://github.com/indutny/node-spdy instead of https://github.com/molnarg/node-http2

The spdy module does in fact support full HTTP/2 despite it's name and works out-of-the-box with Express.js

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

No branches or pull requests

7 participants