Skip to content

HttpIncomingMessage.ts

Common model for incoming HTTP messages.

HttpIncomingMessage is used by server requests and client responses to expose headers, an optional remote address, and body accessors. This module provides decoders for JSON bodies, URL-encoded bodies, and headers, plus the shared body-size setting and inspection helper used by request and response implementations.

Since v4.0.0



Builds an inspectable object for an incoming message, redacting headers and including a synchronously readable JSON or text body when available.

Signature

declare const inspect: <E>(self: HttpIncomingMessage<E>, that: object) => object

Source

Since v4.0.0

Returns true when a value is an HttpIncomingMessage.

Signature

declare const isHttpIncomingMessage: (u: unknown) => u is HttpIncomingMessage

Source

Since v4.0.0

Common model for incoming HTTP messages, with headers, remote address, and effectful body accessors.

Signature

export interface HttpIncomingMessage<E = unknown> extends Inspectable.Inspectable {
readonly [TypeId]: typeof TypeId
readonly headers: Headers.Headers
readonly remoteAddress: Option.Option<string>
readonly json: Effect.Effect<Schema.Json, E>
readonly text: Effect.Effect<string, E>
readonly urlParamsBody: Effect.Effect<UrlParams.UrlParams, E>
readonly arrayBuffer: Effect.Effect<ArrayBuffer, E>
readonly stream: Stream.Stream<Uint8Array, E>
}

Source

Since v4.0.0

Context reference for the optional maximum size allowed when reading an incoming message body.

Signature

declare const MaxBodySize: Context.Reference<FileSystem.Size | undefined>

Source

Since v4.0.0

Creates a decoder that reads an incoming message’s JSON body and decodes it with the supplied schema.

Signature

declare const schemaBodyJson: <S extends Schema.Constraint>(
schema: S,
options?: ParseOptions | undefined
) => <E>(self: HttpIncomingMessage<E>) => Effect.Effect<S["Type"], E | Schema.SchemaError, S["DecodingServices"]>

Source

Since v4.0.0

Creates a decoder that reads an incoming message’s URL-encoded body parameters and decodes them with the supplied schema.

Signature

declare const schemaBodyUrlParams: <
A,
I extends Readonly<Record<string, string | ReadonlyArray<string> | undefined>>,
RD,
RE
>(
schema: Schema.Codec<A, I, RD, RE>,
options?: ParseOptions | undefined
) => <E>(self: HttpIncomingMessage<E>) => Effect.Effect<A, E | Schema.SchemaError, RD>

Source

Since v4.0.0

Creates a decoder that validates and decodes an incoming message’s headers with the supplied schema.

Signature

declare const schemaHeaders: <A, I extends Readonly<Record<string, string | undefined>>, RD, RE>(
schema: Schema.Codec<A, I, RD, RE>,
options?: ParseOptions | undefined
) => <E>(self: HttpIncomingMessage<E>) => Effect.Effect<A, Schema.SchemaError, RD>

Source

Since v4.0.0

Type identifier for HttpIncomingMessage values.

Signature

declare const TypeId: "~effect/http/HttpIncomingMessage"

Source

Since v4.0.0