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.
bodyContentTypeholds the inferred type of the builder's body.nullsuppresses that header. FormData owns its multipart boundary. HTTP inference follows a direct write tobodyand is not copied by object spread; an explicitbodyContentTypeassignment is copied. A replacement body is detected again, so declare its type with acontent-typeheader. For the unchanged body,nullsuppresses 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 explicitcontent-typeheader always wins overbodyContentTypeand detection, whether set by the builder, client defaults, an interceptor, or a rawfetchHandlerrequest.body: undefinedhas no library-inferred Content-Type. Signers should readheaders.get('content-type') ?? request.bodyContentType; do not configure internal fields. endpointis the path with path parameters filled in;baseEndpointis the client endpoint.- Interceptors see
queryParamsasnew URLSearchParams(queryString). A builder that returnsURLSearchParamspasses that instance through. operationis a static, low-cardinality endpoint identity for telemetry and diagnostics.downloadProgressanduploadProgressare theonDownloadProgressandonUploadProgresshooks ofHttpExecuteOptions.responseTypeanderrorResponseTypeare readonly: they are derived from the endpoint'soutputanderrorstruct kinds and must not be changed. Each is set only when its struct is declared. An interceptor that short-circuits withmakeResponsereads them to match the transport.
Members
Prop
Type
signal? AbortSignal | undefinedbaseEndpoint? string | undefinedTrusted absolute base; its origin and directory bound the resolved endpoint path.
body? string | number | boolean | object | ArrayBuffer | Blob | FormData | ReadableStream<Uint8Array<ArrayBufferLike>> | URLSearchParams | null | undefinedbodyContentType? string | null | undefinedCurrent 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 | undefinedendpoint stringRelative path validated after building and again when an interceptor calls the transport.
headers? Headers | undefinedHTTP interceptors see declared headers; detected Content-Type is applied at the Fetch boundary.
method stringoperation? string | undefinedStatic, low-cardinality endpoint identity for telemetry and diagnostics.
queryParams? URLSearchParams | undefinedqueryString? string | undefinedresponseType? HttpResponseType | undefinedRepresentation 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 | undefinedRepresentation 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 | undefinedwithCredentials? boolean | undefinedxsrf? { cookieName: string; headerName: string; tokenProvider?: (context: { request: HttpRequest; }) => string | null | undefined; } | undefined