Skip to content

Commit

Permalink
http2: compatibility with http API & push
Browse files Browse the repository at this point in the history
PR-Url: nodejs#47
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
sebdeckers authored and jasnell committed Jun 22, 2017
1 parent d5dca6e commit 2c7303d
Show file tree
Hide file tree
Showing 14 changed files with 671 additions and 175 deletions.
18 changes: 8 additions & 10 deletions doc/http2-implementation-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,16 @@ const server = http2.createSecureServer(options, (req, res) => {

res.writeHead(200, {'content-type': 'text/html'});

const favicon = res.createPushResponse();
favicon.path = '/favicon.ico';
favicon.push((req, res) => {
res.setHeader('content-type', 'image/jpeg');
fs.createReadStream('/some/image.jpg').pipe(res);
const favicon = res.createPushRequest({':path': '/favicon.ico'});
favicon.push((err, res) => {
res.setHeader('content-type', 'image/png');
fs.createReadStream('/some/logo.png').pipe(res);
});

const pushResponse = res.createPushResponse();
pushResponse.path = '/image.jpg';
pushResponse.push((req, res) => {
const pushResponse = res.createPushRequest({':path': '/image.jpg'});
pushResponse.push((err, res) => {
res.setHeader('content-type', 'image/jpeg');
fs.createReadStream('/some/image/jpg').pipe(res);
fs.createReadStream('/some/image.jpg').pipe(res);
});

res.end('<html><head><link rel="preload" href="/favicon.ico"/></head>' +
Expand Down Expand Up @@ -299,7 +297,7 @@ The `'rst-stream'` event is emitted when a RST-STREAM frame is received.
### Method: `response.writeHeader(statusCode, headers)`
### Method: `response.write()`
### Method: `response.end()`
### Method: `response.createPushResponse()`
### Method: `response.createPushRequest(headers)`

## HTTP2.createServerSession(options)

Expand Down
Loading

0 comments on commit 2c7303d

Please sign in to comment.