response.addTrailers()

response.addTrailers(headers) This method adds HTTP trailing headers (a header but at the end of the message) to the response. Trailers will only be emitted if chunked encoding is used for the response; if it is not (e.g., if the request was HTTP/1.0), they will be silently discarded. Note that HTTP requires the Trailer header to be sent if you intend to emit trailers, with a list of the header fields in its value. E.g., response.writeHead(200, { 'Content-Type': 'text/plain',

response event (http.ClientRequest)

Event: 'response' function (response) { } Emitted when a response is received to this request. This event is emitted only once. The response argument will be an instance of http.IncomingMessage. Options: host: A domain name or IP address of the server to issue the request to. port: Port of remote server. socketPath: Unix Domain Socket (use one of host:port or socketPath)

resize event (WriteStream)

Event: 'resize' function () {} Emitted by refreshSize() when either of the columns or rows properties has changed. process.stdout.on('resize', () => { console.log('screen size has changed!'); console.log(`${process.stdout.columns}x${process.stdout.rows}`); });

reset event (REPLServer)

Event: 'reset' function (context) {} Emitted when the REPL's context is reset. This happens when you type .clear. If you start the repl with { useGlobal: true } then this event will never be emitted. Example of listening for reset: // Extend the initial repl context. var replServer = repl.start({ options ... }); someExtension.extend(r.context); // When a new context is created extend it as well. replServer.on('reset', (context) => { console.log('repl has a new context'); someExtensio

request.write()

request.write(chunk[, encoding][, callback]) Sends a chunk of the body. By calling this method many times, the user can stream a request body to a server--in that case it is suggested to use the ['Transfer-Encoding', 'chunked'] header line when creating the request. The chunk argument should be a Buffer or a string. The encoding argument is optional and only applies when chunk is a string. Defaults to 'utf8'. The callback argument is optional and will be called when this chunk of data is flu

request.setTimeout()

request.setTimeout(timeout[, callback]) Once a socket is assigned to this request and is connected socket.setTimeout() will be called. timeout {Number} Milliseconds before a request is considered to be timed out. callback {Function} Optional function to be called when a timeout occurs. Same as binding to the timeout event.

request.setSocketKeepAlive()

request.setSocketKeepAlive([enable][, initialDelay]) Once a socket is assigned to this request and is connected socket.setKeepAlive() will be called.

request.setNoDelay()

request.setNoDelay([noDelay]) Once a socket is assigned to this request and is connected socket.setNoDelay() will be called.

request.flushHeaders()

request.flushHeaders() Flush the request headers. For efficiency reasons, Node.js normally buffers the request headers until you call request.end() or write the first chunk of request data. It then tries hard to pack the request headers and data into a single TCP packet. That's usually what you want (it saves a TCP round-trip) but not when the first data isn't sent until possibly much later. request.flushHeaders() lets you bypass the optimization and kickstart the request.

request.end()

request.end([data][, encoding][, callback]) Finishes sending the request. If any parts of the body are unsent, it will flush them to the stream. If the request is chunked, this will send the terminating '0\r\n\r\n'. If data is specified, it is equivalent to calling response.write(data, encoding) followed by request.end(callback). If callback is specified, it will be called when the request stream is finished.