Skip to content
This repository was archived by the owner on Jul 6, 2018. It is now read-only.

Commit cee5479

Browse files
sebdeckersmcollina
authored andcommitted
http2: compatibility with http API & push
PR-Url: #47 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 14971f5 commit cee5479

14 files changed

+671
-175
lines changed

doc/http2-implementation-notes.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,16 @@ const server = http2.createSecureServer(options, (req, res) => {
5050

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

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

60-
const pushResponse = res.createPushResponse();
61-
pushResponse.path = '/image.jpg';
62-
pushResponse.push((req, res) => {
59+
const pushResponse = res.createPushRequest({':path': '/image.jpg'});
60+
pushResponse.push((err, res) => {
6361
res.setHeader('content-type', 'image/jpeg');
64-
fs.createReadStream('/some/image/jpg').pipe(res);
62+
fs.createReadStream('/some/image.jpg').pipe(res);
6563
});
6664

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

304302
## HTTP2.createServerSession(options)
305303

0 commit comments

Comments
 (0)