NodeOutgoingMessage
NodeOutgoingMessage is the low-level outgoing response interface. It combines Node.js Writable with the core fields of http.ServerResponse. HttpOutgoing extends this interface with higher-level helpers.
import { NodeOutgoingMessage } from '@opra/http';
Properties
These properties and methods are picked from Node.js http.ServerResponse:
| Property | Type | Description |
|---|---|---|
req | NodeIncomingMessage | The paired incoming request. |
statusCode | number | HTTP status code. |
statusMessage | string | HTTP status message. |
headersSent | boolean | true after headers have been flushed. |
sendDate | boolean | Whether to automatically send the Date header. |
Methods
| Method | Description |
|---|---|
setHeader(name, value) | Set a response header. |
appendHeader(name, value) | Append to an existing header value. |
getHeader(name) | Get a header value. |
getHeaders() | Get all headers as an object. |
getHeaderNames() | Get all header names. |
getRawHeaderNames() | Get raw header names. |
hasHeader(name) | Check if a header is set. |
removeHeader(name) | Remove a header. |
addTrailers(headers) | Add trailing headers. |
flushHeaders() | Flush the response headers immediately. |
Namespace
NodeOutgoingMessage.from(init)
NodeOutgoingMessage.from(init: Initiator): NodeOutgoingMessage
Creates a NodeOutgoingMessage from an Initiator object.
Interfaces
NodeOutgoingMessage.Initiator
Used with NodeOutgoingMessage.from() to construct a response from a plain object.
| Property | Type | Description |
|---|---|---|
req | NodeIncomingMessage | The paired incoming request (required). |
statusCode | number | undefined | HTTP status code. |
statusMessage | string | undefined | HTTP status message. |
headers | OutgoingHttpHeaders | Headers | Map<string, any> | string[] | undefined | Response headers. |
chunkedEncoding | boolean | undefined | Whether to use chunked transfer encoding. |
sendDate | boolean | undefined | Whether to send the Date header automatically. |
strictContentLength | boolean | undefined | Enforce strict content-length validation. |
body | string | Iterable<any> | AsyncIterable<any> | Object | undefined | Response body. |
parsedUrl | URL | undefined | Pre-parsed URL for the request. |