Options
All
  • Public
  • Public/Protected
  • All
Menu

@alterior/http

Index

Type aliases

HttpEvent

Union type for all possible events on the response stream.

Typed according to the expected type of the response.

Type parameters

  • T

HttpObserve

HttpObserve: "body" | "events" | "response"

Variables

Const HTTP_INTERCEPTORS

HTTP_INTERCEPTORS: InjectionToken<HttpInterceptor[]> = new InjectionToken<HttpInterceptor[]>('HTTP_INTERCEPTORS')

A multi-provider token which represents the array of HttpInterceptors that are registered.

Const SERVER_HTTP_PROVIDERS

SERVER_HTTP_PROVIDERS: Provider[] = [{provide: XhrFactory, useClass: ServerXhr},{provide: HttpHandler,useFactory: zoneWrappedInterceptingHandler,deps: [HttpBackend, Injector]}]

Const XSRF_COOKIE_NAME

XSRF_COOKIE_NAME: InjectionToken<string> = new InjectionToken<string>('XSRF_COOKIE_NAME')

Const XSRF_HEADER_NAME

XSRF_HEADER_NAME: InjectionToken<string> = new InjectionToken<string>('XSRF_HEADER_NAME')

Const XSSI_PREFIX

XSSI_PREFIX: RegExp = /^\)\]\}',?\n/

Const isAbsoluteUrl

isAbsoluteUrl: RegExp = /^[a-zA-Z\-\+.]+:\/\//

Functions

_maybeConvertBody

  • _maybeConvertBody(responseType: string, body: ArrayBuffer | Blob | string | number | Object | (string | number | Object)[] | null): ArrayBuffer | Blob | string | number | Object | (string | number | Object)[] | null
  • Convert a response body to the requested type.

    Parameters

    • responseType: string
    • body: ArrayBuffer | Blob | string | number | Object | (string | number | Object)[] | null

    Returns ArrayBuffer | Blob | string | number | Object | (string | number | Object)[] | null

_toArrayBufferBody

  • _toArrayBufferBody(body: ArrayBuffer | Blob | string | number | Object | (string | number | Object)[]): ArrayBuffer
  • Helper function to convert a response body to an ArrayBuffer.

    Parameters

    • body: ArrayBuffer | Blob | string | number | Object | (string | number | Object)[]

    Returns ArrayBuffer

_toBlob

  • _toBlob(body: ArrayBuffer | Blob | string | number | Object | (string | number | Object)[]): Blob
  • Helper function to convert a response body to a Blob.

    Parameters

    • body: ArrayBuffer | Blob | string | number | Object | (string | number | Object)[]

    Returns Blob

_toJsonBody

  • _toJsonBody(body: ArrayBuffer | Blob | string | number | Object | (string | number | Object)[], format?: string): Object | string | number | (string | number | Object)[]
  • Helper function to convert a response body to JSON data.

    Parameters

    • body: ArrayBuffer | Blob | string | number | Object | (string | number | Object)[]
    • Default value format: string = "JSON"

    Returns Object | string | number | (string | number | Object)[]

_toTextBody

  • _toTextBody(body: ArrayBuffer | Blob | string | number | Object | (string | number | Object)[]): string
  • Helper function to convert a response body to a string.

    Parameters

    • body: ArrayBuffer | Blob | string | number | Object | (string | number | Object)[]

    Returns string

addBody

  • addBody<T>(options: { headers?: HttpHeaders | {}; observe?: HttpObserve; params?: HttpParams | {}; reportProgress?: boolean; responseType?: "arraybuffer" | "blob" | "json" | "text"; withCredentials?: boolean }, body: T | null): any
  • Construct an instance of HttpRequestOptions<T> from a source HttpMethodOptions and the given body. Basically, this clones the object and adds the body.

    Type parameters

    • T

    Parameters

    • options: { headers?: HttpHeaders | {}; observe?: HttpObserve; params?: HttpParams | {}; reportProgress?: boolean; responseType?: "arraybuffer" | "blob" | "json" | "text"; withCredentials?: boolean }
      • Optional headers?: HttpHeaders | {}
      • Optional observe?: HttpObserve
      • Optional params?: HttpParams | {}
      • Optional reportProgress?: boolean
      • Optional responseType?: "arraybuffer" | "blob" | "json" | "text"
      • Optional withCredentials?: boolean
    • body: T | null

    Returns any

getResponseUrl

  • getResponseUrl(xhr: any): string | null
  • Determine an appropriate URL for the response, by checking either XMLHttpRequest.responseURL or the X-Request-URL header.

    Parameters

    • xhr: any

    Returns string | null

interceptingHandler

  • Constructs an HttpHandler that applies interceptors to a request before passing it to the given HttpBackend.

    Use as a factory function within HttpClientModule.

    Parameters

    Returns HttpHandler

isArrayBuffer

  • isArrayBuffer(value: any): value is ArrayBuffer
  • Safely assert whether the given value is an ArrayBuffer.

    In some execution environments ArrayBuffer is not defined.

    Parameters

    • value: any

    Returns value is ArrayBuffer

isBlob

  • isBlob(value: any): value is Blob
  • Safely assert whether the given value is a Blob.

    In some execution environments Blob is not defined.

    Parameters

    • value: any

    Returns value is Blob

isFormData

  • isFormData(value: any): value is FormData
  • Safely assert whether the given value is a FormData instance.

    In some execution environments FormData is not defined.

    Parameters

    • value: any

    Returns value is FormData

jsonpCallbackContext

  • jsonpCallbackContext(): Object
  • Factory function that determines where to store JSONP callbacks.

    Ordinarily JSONP callbacks are stored on the window object, but this may not exist in test environments. In that case, callbacks are stored on an anonymous object instead.

    Returns Object

mightHaveBody

  • mightHaveBody(method: string): boolean
  • Determine whether the given HTTP method may include a body.

    Parameters

    • method: string

    Returns boolean

paramParser

standardEncoding

  • standardEncoding(v: string): string
  • Parameters

    • v: string

    Returns string

validateRequestUrl

  • validateRequestUrl(url: string): void
  • Parameters

    • url: string

    Returns void

zoneWrappedInterceptingHandler

Generated using TypeDoc