Skip to content

Commit

Permalink
doc: fix http2 sample code for http2.md
Browse files Browse the repository at this point in the history
PR-URL: #14667
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
kakts authored and addaleax committed Aug 10, 2017
1 parent 52a0d97 commit 0eb7268
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ const {
HTTP2_HEADER_CONTENT_TYPE
} = http2.constants;

const server = http.createServer();
const server = http2.createServer();
server.on('stream', (stream, headers, flags) => {
const method = headers[HTTP2_HEADER_METHOD];
const path = headers[HTTP2_HEADER_PATH];
Expand Down Expand Up @@ -1328,7 +1328,7 @@ const {

const options = getOptionsSomehow();

const server = http.createSecureServer(options);
const server = http2.createSecureServer(options);
server.on('stream', (stream, headers, flags) => {
const method = headers[HTTP2_HEADER_METHOD];
const path = headers[HTTP2_HEADER_PATH];
Expand Down Expand Up @@ -2373,7 +2373,7 @@ to [`response.writeHead()`][] given precedence.

```js
// returns content-type = text/plain
const server = http.createServer((req, res) => {
const server = http2.createServer((req, res) => {
res.setHeader('Content-Type', 'text/html');
res.setHeader('X-Foo', 'bar');
res.writeHead(200, { 'Content-Type': 'text/plain' });
Expand Down Expand Up @@ -2416,8 +2416,8 @@ via `response.connection`.
Example:

```js
const http = require('http');
const server = http.createServer((req, res) => {
const http2 = require('http2');
const server = http2.createServer((req, res) => {
const ip = req.socket.remoteAddress;
const port = req.socket.remotePort;
res.end(`Your IP address is ${ip} and your source port is ${port}.`);
Expand Down

0 comments on commit 0eb7268

Please sign in to comment.