Skip to content

HttpResponse

Defined in: index.cts:79

Outgoing HTTP response passed to handleHttpRequest.

Instances are proper Node.js stream.Writable objects — someReadable.pipe(res) works. Chunks from write() / end() and piped data are buffered; the complete response is sent once the handler’s Promise resolves. Real-time streaming to the client is not supported; for push-based patterns use WebSockets instead.

setHeader(), getHeader(), removeHeader(), writeHead(status, [reason,] [headers]), statusCode = N, write(chunk) and end([chunk]) all work as expected. Array values for setHeader() produce multiple header lines (e.g. for Set-Cookie). There are no trailers and no upgrade hook for non-WebSocket upgrades.

  • EventEmitter

statusCode: number

Defined in: index.cts:80


readonly writableEnded: boolean

Defined in: index.cts:91

True once end() has been called.


readonly writableFinished: boolean

Defined in: index.cts:93

True once the ‘finish’ event has fired.

setHeader(name, value): void

Defined in: index.cts:81

string

string | string[]

void


getHeader(name): string | string[]

Defined in: index.cts:82

string

string | string[]


getHeaders(): Record<string, string | string[]>

Defined in: index.cts:83

Record<string, string | string[]>


hasHeader(name): boolean

Defined in: index.cts:84

string

boolean


removeHeader(name): void

Defined in: index.cts:85

string

void


writeHead(statusCode, headers?): this

Defined in: index.cts:86

number

Record<string, string | string[]>

this

writeHead(statusCode, reasonPhrase, headers?): this

Defined in: index.cts:87

number

string

Record<string, string | string[]>

this


write(chunk, encoding?, cb?): boolean

Defined in: index.cts:88

any

string

() => void

boolean


end(chunk?, encoding?, cb?): this

Defined in: index.cts:89

any

string

() => void

this