diff --git a/doc/api/http.md b/doc/api/http.md index 8c04ef2ecbbe3d..48767107affce5 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -47,7 +47,7 @@ list like the following: 'accepT', '*/*' ] ``` -## Class: http.Agent +## Class: `http.Agent` @@ -107,7 +107,7 @@ http.get({ }); ``` -### new Agent(\[options\]) +### `new Agent([options])` @@ -149,7 +149,7 @@ options.agent = keepAliveAgent; http.request(options, onResponseCallback); ``` -### agent.createConnection(options\[, callback\]) +### `agent.createConnection(options[, callback])` @@ -173,7 +173,7 @@ type other than {net.Socket}. `callback` has a signature of `(err, stream)`. -### agent.keepSocketAlive(socket) +### `agent.keepSocketAlive(socket)` @@ -196,7 +196,7 @@ it for use with the next request. The `socket` argument can be an instance of {net.Socket}, a subclass of {stream.Duplex}. -### agent.reuseSocket(socket, request) +### `agent.reuseSocket(socket, request)` @@ -216,7 +216,7 @@ This method can be overridden by a particular `Agent` subclass. The `socket` argument can be an instance of {net.Socket}, a subclass of {stream.Duplex}. -### agent.destroy() +### `agent.destroy()` @@ -229,7 +229,7 @@ the agent when it will no longer be used. Otherwise, sockets may hang open for quite a long time before the server terminates them. -### agent.freeSockets +### `agent.freeSockets` @@ -239,7 +239,7 @@ added: v0.11.4 An object which contains arrays of sockets currently awaiting use by the agent when `keepAlive` is enabled. Do not modify. -### agent.getName(options) +### `agent.getName(options)` @@ -259,7 +259,7 @@ connection can be reused. For an HTTP agent, this returns the name includes the CA, cert, ciphers, and other HTTPS/TLS-specific options that determine socket reusability. -### agent.maxFreeSockets +### `agent.maxFreeSockets` @@ -270,7 +270,7 @@ By default set to 256. For agents with `keepAlive` enabled, this sets the maximum number of sockets that will be left open in the free state. -### agent.maxSockets +### `agent.maxSockets` @@ -280,7 +280,7 @@ added: v0.3.6 By default set to `Infinity`. Determines how many concurrent sockets the agent can have open per origin. Origin is the returned value of [`agent.getName()`][]. -### agent.requests +### `agent.requests` @@ -290,7 +290,7 @@ added: v0.5.9 An object which contains queues of requests that have not yet been assigned to sockets. Do not modify. -### agent.sockets +### `agent.sockets` @@ -300,7 +300,7 @@ added: v0.3.6 An object which contains arrays of sockets currently in use by the agent. Do not modify. -## Class: http.ClientRequest +## Class: `http.ClientRequest` @@ -337,7 +337,7 @@ Unlike the `request` object, if the response closes prematurely, the Node.js does not check whether Content-Length and the length of the body which has been transmitted are equal or not. -### Event: 'abort' +### Event: `'abort'` @@ -345,7 +345,7 @@ added: v1.4.1 Emitted when the request has been aborted by the client. This event is only emitted on the first call to `abort()`. -### Event: 'connect' +### Event: `'connect'` @@ -419,7 +419,7 @@ proxy.listen(1337, '127.0.0.1', () => { }); ``` -### Event: 'continue' +### Event: `'continue'` @@ -428,7 +428,7 @@ Emitted when the server sends a '100 Continue' HTTP response, usually because the request contained 'Expect: 100-continue'. This is an instruction that the client should send the request body. -### Event: 'information' +### Event: `'information'` @@ -470,7 +470,7 @@ traditional HTTP request/response chain, such as web sockets, in-place TLS upgrades, or HTTP 2.0. To be notified of 101 Upgrade notices, listen for the [`'upgrade'`][] event instead. -### Event: 'response' +### Event: `'response'` @@ -480,7 +480,7 @@ added: v0.1.0 Emitted when a response is received to this request. This event is emitted only once. -### Event: 'socket' +### Event: `'socket'` @@ -491,7 +491,7 @@ This event is guaranteed to be passed an instance of the {net.Socket} class, a subclass of {stream.Duplex}, unless the user specifies a socket type other than {net.Socket}. -### Event: 'timeout' +### Event: `'timeout'` @@ -501,7 +501,7 @@ that the socket has been idle. The request must be aborted manually. See also: [`request.setTimeout()`][]. -### Event: 'upgrade' +### Event: `'upgrade'` @@ -562,7 +562,7 @@ srv.listen(1337, '127.0.0.1', () => { }); ``` -### request.abort() +### `request.abort()` @@ -570,7 +570,7 @@ added: v0.3.8 Marks the request as aborting. Calling this will cause remaining data in the response to be dropped and the socket to be destroyed. -### request.aborted +### `request.aborted` @@ -649,7 +649,7 @@ That's usually desired (it saves a TCP round-trip), but not when the first data is not sent until possibly much later. `request.flushHeaders()` bypasses the optimization and kickstarts the request. -### request.getHeader(name) +### `request.getHeader(name)` @@ -673,20 +673,20 @@ const cookie = request.getHeader('Cookie'); // 'cookie' is of type string[] ``` -### request.maxHeadersCount +### `request.maxHeadersCount` * {number} **Default:** `2000` Limits maximum response headers count. If set to 0, no limit will be applied. -### request.path +### `request.path` * {string} The request path. -### request.removeHeader(name) +### `request.removeHeader(name)` @@ -699,7 +699,7 @@ Removes a header that's already defined into headers object. request.removeHeader('Content-Type'); ``` -### request.reusedSocket +### `request.reusedSocket` @@ -780,7 +780,7 @@ or request.setHeader('Cookie', ['type=ninja', 'language=javascript']); ``` -### request.setNoDelay(\[noDelay\]) +### `request.setNoDelay([noDelay])` @@ -790,7 +790,7 @@ added: v0.5.9 Once a socket is assigned to this request and is connected [`socket.setNoDelay()`][] will be called. -### request.setSocketKeepAlive(\[enable\]\[, initialDelay\]) +### `request.setSocketKeepAlive([enable][, initialDelay])` @@ -801,7 +801,7 @@ added: v0.5.9 Once a socket is assigned to this request and is connected [`socket.setKeepAlive()`][] will be called. -### request.setTimeout(timeout\[, callback\]) +### `request.setTimeout(timeout[, callback])` @@ -849,7 +849,7 @@ This property is guaranteed to be an instance of the {net.Socket} class, a subclass of {stream.Duplex}, unless the user specified a socket type other than {net.Socket}. -### request.writableEnded +### `request.writableEnded` @@ -860,7 +860,7 @@ Is `true` after [`request.end()`][] has been called. This property does not indicate whether the data has been flushed, for this use [`request.writableFinished`][] instead. -### request.writableFinished +### `request.writableFinished` @@ -870,7 +870,7 @@ added: v12.7.0 Is `true` if all data has been flushed to the underlying system, immediately before the [`'finish'`][] event is emitted. -### request.write(chunk\[, encoding\]\[, callback\]) +### `request.write(chunk[, encoding][, callback])` @@ -899,14 +899,14 @@ buffer. Returns `false` if all or part of the data was queued in user memory. When `write` function is called with empty string or buffer, it does nothing and waits for more input. -## Class: http.Server +## Class: `http.Server` * Extends: {net.Server} -### Event: 'checkContinue' +### Event: `'checkContinue'` @@ -926,7 +926,7 @@ the request body. When this event is emitted and handled, the [`'request'`][] event will not be emitted. -### Event: 'checkExpectation' +### Event: `'checkExpectation'` @@ -941,7 +941,7 @@ automatically respond with a `417 Expectation Failed` as appropriate. When this event is emitted and handled, the [`'request'`][] event will not be emitted. -### Event: 'clientError' +### Event: `'clientError'` Emitted when the server closes. -### Event: 'connect' +### Event: `'connect'` @@ -1032,7 +1032,7 @@ After this event is emitted, the request's socket will not have a `'data'` event listener, meaning it will need to be bound in order to handle data sent to the server on that socket. -### Event: 'connection' +### Event: `'connection'` @@ -1056,7 +1056,7 @@ This event is guaranteed to be passed an instance of the {net.Socket} class, a subclass of {stream.Duplex}, unless the user specifies a socket type other than {net.Socket}. -### Event: 'request' +### Event: `'request'` @@ -1067,7 +1067,7 @@ added: v0.1.0 Emitted each time there is a request. There may be multiple requests per connection (in the case of HTTP Keep-Alive connections). -### Event: 'upgrade' +### Event: `'upgrade'` @@ -1102,7 +1102,7 @@ added: v0.1.90 Stops the server from accepting new connections. See [`net.Server.close()`][]. -### server.headersTimeout +### `server.headersTimeout` @@ -1122,19 +1122,19 @@ event is emitted on the server object, and (by default) the socket is destroyed. See [`server.timeout`][] for more information on how timeout behavior can be customized. -### server.listen() +### `server.listen()` Starts the HTTP server listening for connections. This method is identical to [`server.listen()`][] from [`net.Server`][]. -### server.listening +### `server.listening` * {boolean} Indicates whether or not the server is listening for connections. -### server.maxHeadersCount +### `server.maxHeadersCount` @@ -1143,7 +1143,7 @@ added: v0.7.0 Limits maximum incoming headers count. If set to 0, no limit will be applied. -### server.setTimeout(\[msecs\]\[, callback\]) +### `server.setTimeout([msecs][, callback])` @@ -1207,7 +1207,7 @@ to 8.0.0, which did not have a keep-alive timeout. The socket timeout logic is set up on connection, so changing this value only affects new connections to the server, not any existing connections. -## Class: http.ServerResponse +## Class: `http.ServerResponse` @@ -1217,14 +1217,14 @@ added: v0.1.17 This object is created internally by an HTTP server — not by the user. It is passed as the second parameter to the [`'request'`][] event. -### Event: 'close' +### Event: `'close'` Indicates that the underlying connection was terminated. -### Event: 'finish' +### Event: `'finish'` @@ -1234,7 +1234,7 @@ emitted when the last segment of the response headers and body have been handed off to the operating system for transmission over the network. It does not imply that the client has received anything yet. -### response.addTrailers(headers) +### `response.addTrailers(headers)` @@ -1262,7 +1262,7 @@ response.end(); Attempting to set a header field name or value that contains invalid characters will result in a [`TypeError`][] being thrown. -### response.connection +### `response.connection` See [`writable.cork()`][]. -### response.end(\[data\[, encoding\]\]\[, callback\]) +### `response.end([data[, encoding]][, callback])` Flushes the response headers. See also: [`request.flushHeaders()`][]. -### response.getHeader(name) +### `response.getHeader(name)` @@ -1349,7 +1349,7 @@ const setCookie = response.getHeader('set-cookie'); // setCookie is of type string[] ``` -### response.getHeaderNames() +### `response.getHeaderNames()` @@ -1367,7 +1367,7 @@ const headerNames = response.getHeaderNames(); // headerNames === ['foo', 'set-cookie'] ``` -### response.getHeaders() +### `response.getHeaders()` @@ -1393,7 +1393,7 @@ const headers = response.getHeaders(); // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] } ``` -### response.hasHeader(name) +### `response.hasHeader(name)` @@ -1408,7 +1408,7 @@ outgoing headers. The header name matching is case-insensitive. const hasContentType = response.hasHeader('content-type'); ``` -### response.headersSent +### `response.headersSent` @@ -1417,7 +1417,7 @@ added: v0.9.3 Boolean (read-only). True if headers were sent, false otherwise. -### response.removeHeader(name) +### `response.removeHeader(name)` @@ -1430,7 +1430,7 @@ Removes a header that's queued for implicit sending. response.removeHeader('Content-Encoding'); ``` -### response.sendDate +### `response.sendDate` @@ -1443,7 +1443,7 @@ the response if it is not already present in the headers. Defaults to true. This should only be disabled for testing; HTTP requires the Date header in responses. -### response.setHeader(name, value) +### `response.setHeader(name, value)` @@ -1492,7 +1492,7 @@ header will not yield the expected result. If progressive population of headers is desired with potential future retrieval and modification, use [`response.setHeader()`][] instead of [`response.writeHead()`][]. -### response.setTimeout(msecs\[, callback\]) +### `response.setTimeout(msecs[, callback])` @@ -1510,7 +1510,7 @@ the server, then sockets are destroyed when they time out. If a handler is assigned to the request, the response, or the server's `'timeout'` events, timed out sockets must be handled explicitly. -### response.socket +### `response.socket` @@ -1536,7 +1536,7 @@ This property is guaranteed to be an instance of the {net.Socket} class, a subclass of {stream.Duplex}, unless the user specified a socket type other than {net.Socket}. -### response.statusCode +### `response.statusCode` @@ -1554,7 +1554,7 @@ response.statusCode = 404; After response header was sent to the client, this property indicates the status code which was sent out. -### response.statusMessage +### `response.statusMessage` @@ -1573,14 +1573,14 @@ response.statusMessage = 'Not found'; After response header was sent to the client, this property indicates the status message which was sent out. -### response.uncork() +### `response.uncork()` See [`writable.uncork()`][]. -### response.writableEnded +### `response.writableEnded` @@ -1591,7 +1591,7 @@ Is `true` after [`response.end()`][] has been called. This property does not indicate whether the data has been flushed, for this use [`response.writableFinished`][] instead. -### response.writableFinished +### `response.writableFinished` @@ -1601,7 +1601,7 @@ added: v12.7.0 Is `true` if all data has been flushed to the underlying system, immediately before the [`'finish'`][] event is emitted. -### response.write(chunk\[, encoding\]\[, callback\]) +### `response.write(chunk[, encoding][, callback])` @@ -1638,7 +1638,7 @@ Returns `true` if the entire data was flushed successfully to the kernel buffer. Returns `false` if all or part of the data was queued in user memory. `'drain'` will be emitted when the buffer is free again. -### response.writeContinue() +### `response.writeContinue()` @@ -1647,7 +1647,7 @@ Sends a HTTP/1.1 100 Continue message to the client, indicating that the request body should be sent. See the [`'checkContinue'`][] event on `Server`. -### response.writeHead(statusCode\[, statusMessage\]\[, headers\]) +### `response.writeHead(statusCode[, statusMessage][, headers])` @@ -1728,7 +1728,7 @@ added: v10.0.0 Sends a HTTP/1.1 102 Processing message to the client, indicating that the request body should be sent. -## Class: http.IncomingMessage +## Class: `http.IncomingMessage` Emitted when the request has been aborted. -### Event: 'close' +### Event: `'close'` Indicates that the underlying connection was closed. -### message.aborted +### `message.aborted` @@ -1768,7 +1768,7 @@ added: v10.1.0 The `message.aborted` property will be `true` if the request has been aborted. -### message.complete +### `message.complete` @@ -1796,7 +1796,7 @@ const req = http.request({ }); ``` -### message.destroy(\[error\]) +### `message.destroy([error])` @@ -1807,7 +1807,7 @@ Calls `destroy()` on the socket that received the `IncomingMessage`. If `error` is provided, an `'error'` event is emitted on the socket and `error` is passed as an argument to any listeners on the event. -### message.headers +### `message.headers` @@ -1838,7 +1838,7 @@ header name: * For duplicate `cookie` headers, the values are joined together with '; '. * For all other headers, the values are joined together with ', '. -### message.httpVersion +### `message.httpVersion` @@ -1852,7 +1852,7 @@ Probably either `'1.1'` or `'1.0'`. Also `message.httpVersionMajor` is the first integer and `message.httpVersionMinor` is the second. -### message.method +### `message.method` @@ -1863,7 +1863,7 @@ added: v0.1.1 The request method as a string. Read only. Examples: `'GET'`, `'DELETE'`. -### message.rawHeaders +### `message.rawHeaders` @@ -1892,7 +1892,7 @@ Header names are not lowercased, and duplicates are not merged. console.log(request.rawHeaders); ``` -### message.rawTrailers +### `message.rawTrailers` @@ -1902,7 +1902,7 @@ added: v0.11.6 The raw request/response trailer keys and values exactly as they were received. Only populated at the `'end'` event. -### message.setTimeout(msecs\[, callback\]) +### `message.setTimeout(msecs[, callback])` @@ -1913,7 +1913,7 @@ added: v0.5.9 Calls `message.connection.setTimeout(msecs, callback)`. -### message.socket +### `message.socket` @@ -1929,7 +1929,7 @@ This property is guaranteed to be an instance of the {net.Socket} class, a subclass of {stream.Duplex}, unless the user specified a socket type other than {net.Socket}. -### message.statusCode +### `message.statusCode` @@ -1940,7 +1940,7 @@ added: v0.1.1 The 3-digit HTTP response status code. E.G. `404`. -### message.statusMessage +### `message.statusMessage` @@ -1952,7 +1952,7 @@ added: v0.11.10 The HTTP response status message (reason phrase). E.G. `OK` or `Internal Server Error`. -### message.trailers +### `message.trailers` @@ -1961,7 +1961,7 @@ added: v0.3.0 The request/response trailers object. Only populated at the `'end'` event. -### message.url +### `message.url` @@ -2007,7 +2007,7 @@ URL { } ``` -## http.METHODS +## `http.METHODS` @@ -2016,7 +2016,7 @@ added: v0.11.8 A list of the HTTP methods that are supported by the parser. -## http.STATUS_CODES +## `http.STATUS_CODES` @@ -2027,7 +2027,7 @@ A collection of all the standard HTTP response status codes, and the short description of each. For example, `http.STATUS_CODES[404] === 'Not Found'`. -## http.createServer(\[options\]\[, requestListener\]) +## `http.createServer([options][, requestListener])` @@ -2137,7 +2137,7 @@ added: v0.5.9 Global instance of `Agent` which is used as the default for all HTTP client requests. -## http.maxHeaderSize +## `http.maxHeaderSize` @@ -2150,8 +2150,8 @@ Defaults to 8KB. Configurable using the [`--max-http-header-size`][] CLI option. This can be overridden for servers and client requests by passing the `maxHeaderSize` option. -## http.request(options\[, callback\]) -## http.request(url\[, options\]\[, callback\]) +## `http.request(options[, callback])` +## `http.request(url[, options][, callback])`