Defjs
Core

HttpRequest

Normalized outgoing HTTP request seen by transports, handlers, interceptors, and fetchHandler after the builder runs.

@defjs/core · Type

Signature

interface HttpRequest {
  signal?: AbortSignal;
  baseEndpoint?: string;
  body?:
    | Blob
    | ArrayBuffer
    | FormData
    | URLSearchParams
    | ReadableStream<Uint8Array>
    | object
    | string
    | number
    | boolean
    | null;
  bodyContentType?: string | null;
  downloadProgress?: HttpProgressFn;
  endpoint: string;
  headers?: Headers;
  method: string;
  operation?: string;
  queryParams?: URLSearchParams;
  queryString?: string;
  readonly responseType?: HttpResponseType;
  readonly errorResponseType?: HttpResponseType;
  uploadProgress?: HttpProgressFn;
  withCredentials?: boolean;
  xsrf?: {
    cookieName: string;
    headerName: string;
    tokenProvider?: (context: {
      request: HttpRequest;
    }) => string | null | undefined;
  };
}

body is already the wire value. For JSON that is a JSON text string; sign HMAC or digests against that string (or other final bytes), not the original struct input.

  • bodyContentType holds the inferred type of the builder's body. null suppresses that header. FormData owns its multipart boundary. HTTP inference follows a direct write to body and is not copied by object spread; an explicit bodyContentType assignment is copied. A replacement body is detected again, so declare its type with a content-type header. For the unchanged body, null suppresses library inference when there is no explicit header, but native Fetch may add its own string type.
  • HTTP never writes inferred Content-Type into headers; interceptors see only declared headers. An explicit content-type header always wins over bodyContentType and detection, whether set by the builder, client defaults, an interceptor, or a raw fetchHandler request. body: undefined has no library-inferred Content-Type. Signers should read headers.get('content-type') ?? request.bodyContentType; do not configure internal fields.
  • endpoint is the path with path parameters filled in; baseEndpoint is the client endpoint.
  • Interceptors see queryParams as new URLSearchParams(queryString). A builder that returns URLSearchParams passes that instance through.
  • operation is a static, low-cardinality endpoint identity for telemetry and diagnostics.
  • downloadProgress and uploadProgress are the onDownloadProgress and onUploadProgress hooks of HttpExecuteOptions.
  • responseType and errorResponseType are readonly: they are derived from the endpoint's output and error struct kinds and must not be changed. Each is set only when its struct is declared. An interceptor that short-circuits with makeResponse reads them to match the transport.

Members

Prop

Type

signal? AbortSignal | undefined
baseEndpoint? string | undefined

Trusted absolute base; its origin and directory bound the resolved endpoint path.

body? string | number | boolean | object | ArrayBuffer | Blob | FormData | ReadableStream<Uint8Array<ArrayBufferLike>> | URLSearchParams | null | undefined
bodyContentType? string | null | undefined

Current body media type; null suppresses the header. FormData owns its boundary. HTTP inference follows direct body mutations and is not copied by object spread; explicit assignments are copied.

downloadProgress? HttpProgressFn | undefined
endpoint string

Relative path validated after building and again when an interceptor calls the transport.

headers? Headers | undefined

HTTP interceptors see declared headers; detected Content-Type is applied at the Fetch boundary.

method string
operation? string | undefined

Static, low-cardinality endpoint identity for telemetry and diagnostics.

queryParams? URLSearchParams | undefined
queryString? string | undefined
responseType? HttpResponseType | undefined

Representation for a 2xx body, derived from the endpoint output struct kind. Set only when output is declared. Interceptors that short-circuit with makeResponse read this to match the transport. Must not be changed. undefined leaves the 2xx body unread.

errorResponseType? HttpResponseType | undefined

Representation for a non-2xx body, derived from the endpoint error struct kind. Set only when error is declared. Must not be changed. undefined leaves the non-2xx body unread and does not fall back to responseType.

uploadProgress? HttpProgressFn | undefined
withCredentials? boolean | undefined
xsrf? { cookieName: string; headerName: string; tokenProvider?: (context: { request: HttpRequest; }) => string | null | undefined; } | undefined
Edit this page on GitHub
Released under the MIT License. · Copyright © 2026 MunMunMiao