Skip to content

Commit 371ade6

Browse files
committed
Update the example server to have a safe push example
1 parent 33685c5 commit 371ade6

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Version history
22
===============
33

4+
### 3.1.2 (2015-02-17) ###
5+
6+
* Update the example server to have a safe push example.
7+
48
### 3.1.1 (2015-01-29) ###
59

610
* Bugfix release.

example/server.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ function onRequest(request, response) {
1212

1313
// Serving server.js from cache. Useful for microbenchmarks.
1414
if (request.url === cachedUrl) {
15+
if (response.push) {
16+
// Also push down the client js, since it's possible if the requester wants
17+
// one, they want both.
18+
var push = response.push('/client.js');
19+
push.writeHead(200);
20+
fs.createReadStream(path.join(__dirname, '/client.js')).pipe(push);
21+
}
1522
response.end(cachedFile);
1623
}
1724

1825
// Reading file from disk if it exists and is safe.
1926
else if ((filename.indexOf(__dirname) === 0) && fs.existsSync(filename) && fs.statSync(filename).isFile()) {
2027
response.writeHead('200');
2128

22-
// If they download the certificate, push the private key too, they might need it.
23-
if (response.push && request.url === '/localhost.crt') {
24-
var push = response.push('/localhost.key');
25-
push.writeHead(200);
26-
fs.createReadStream(path.join(__dirname, '/localhost.key')).pipe(push);
27-
}
28-
2929
fs.createReadStream(filename).pipe(response);
3030
}
3131

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "http2",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"description": "An HTTP/2 client and server implementation",
55
"main": "lib/index.js",
66
"engines" : {

0 commit comments

Comments
 (0)