Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WebClientSession

An asynchronous sessions aware HTTP / HTTP/2 client called WebClientSession.

This client wraps a WebClient and makes it session aware adding features to it:

  • Per client headers, to be send with every request
  • Per client cookies, to be send with every request
  • Automatic storage and sending of cookies received from the server(s)

The client honors the cookies attributes:

  • domain
  • path
  • secure
  • max-age and expires

Hierarchy

Index

Methods

addHeader

  • Configure the client to add an HTTP header to every request.

    Parameters

    • name: string
    • value: string

    Returns WebClientSession

  • Configure the client to add an HTTP header to every request.

    Parameters

    • name: string
    • value: string

    Returns WebClientSession

  • Configure the client to add an HTTP header to every request.

    Parameters

    • name: string
    • values: any

    Returns WebClientSession

  • Configure the client to add an HTTP header to every request.

    Parameters

    • name: string
    • values: any

    Returns WebClientSession

close

  • close(): void
  • Close the client. Closing will close down any pooled connections. Clients should always be closed after use.

    Returns void

cookieStore

  • cookieStore(): any
  • Returns this client's CookieStore

    All cookies added to this store will be sent with every request. The CookieStore honors the domain, path, secure and max-age properties of received cookies and is automatically updated with cookies present in responses received by this client.

    Returns any

delete

  • delete(requestURI: string): HttpRequest<Buffer>
  • delete(requestURI: UriTemplate): HttpRequest<Buffer>
  • delete(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • delete(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • delete(host: string, requestURI: string): HttpRequest<Buffer>
  • delete(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP DELETE request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

deleteAbs

  • deleteAbs(absoluteURI: string): HttpRequest<Buffer>
  • deleteAbs(absoluteURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP DELETE request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP DELETE request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

get

  • get(requestURI: string): HttpRequest<Buffer>
  • get(requestURI: UriTemplate): HttpRequest<Buffer>
  • get(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • get(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • get(host: string, requestURI: string): HttpRequest<Buffer>
  • get(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP GET request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

getAbs

  • Create an HTTP GET request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP GET request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

head

  • head(requestURI: string): HttpRequest<Buffer>
  • head(requestURI: UriTemplate): HttpRequest<Buffer>
  • head(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • head(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • head(host: string, requestURI: string): HttpRequest<Buffer>
  • head(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP HEAD request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

headAbs

  • Create an HTTP HEAD request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP HEAD request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

patch

  • patch(requestURI: string): HttpRequest<Buffer>
  • patch(requestURI: UriTemplate): HttpRequest<Buffer>
  • patch(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • patch(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • patch(host: string, requestURI: string): HttpRequest<Buffer>
  • patch(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP PATCH request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

patchAbs

  • Create an HTTP PATCH request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PATCH request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

post

  • post(requestURI: string): HttpRequest<Buffer>
  • post(requestURI: UriTemplate): HttpRequest<Buffer>
  • post(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • post(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • post(host: string, requestURI: string): HttpRequest<Buffer>
  • post(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP POST request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

postAbs

  • Create an HTTP POST request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP POST request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

put

  • put(requestURI: string): HttpRequest<Buffer>
  • put(requestURI: UriTemplate): HttpRequest<Buffer>
  • put(port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • put(port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • put(host: string, requestURI: string): HttpRequest<Buffer>
  • put(host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP PUT request to send to the server at the default host and port.

    Parameters

    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server at the default host and port.

    Parameters

    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server at the specified host and port.

    Parameters

    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server at the specified host and default port.

    Parameters

    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

putAbs

  • Create an HTTP PUT request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP PUT request to send to the server using an absolute URI, specifying a response handler to receive the response

    Parameters

    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

removeHeader

  • Removes a previously added header.

    Parameters

    • name: string

    Returns WebClientSession

  • Removes a previously added header.

    Parameters

    • name: string

    Returns WebClientSession

request

  • request(method: HttpMethod, port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, port: number, host: string, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, port: number, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, host: string, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, host: string, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, host: string, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, requestURI: string): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, requestURI: UriTemplate): HttpRequest<Buffer>
  • request(method: HttpMethod, options: RequestOptions): HttpRequest<Buffer>
  • request(method: HttpMethod, serverAddress: SocketAddress, options: RequestOptions): HttpRequest<Buffer>
  • Create an HTTP request to send to the server at the specified host and port.

    Parameters

    • method: HttpMethod
    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the specified host and port.

    Parameters

    • method: HttpMethod
    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the port and host parameters.

    The request host header will still be created from the port and host parameters.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • port: number
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the port and host parameters.

    The request host header will still be created from the port and host parameters.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • port: number
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the specified host and default port.

    Parameters

    • method: HttpMethod
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the specified host and default port.

    Parameters

    • method: HttpMethod
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the default port and host parameter.

    The request host header will still be created from the default port and host parameter.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • host: string
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the default port and host parameter.

    The request host header will still be created from the default port and host parameter.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • host: string
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the default host and port.

    Parameters

    • method: HttpMethod
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the default host and port.

    Parameters

    • method: HttpMethod
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the default port and default host.

    The request host header will still be created from the default port and default host.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • requestURI: string

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the default port and default host.

    The request host header will still be created from the default port and default host.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • requestURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server at the specified host and port.

    Parameters

    • method: HttpMethod
    • options: RequestOptions

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#request} using the serverAddress parameter to connect to the server instead of the options parameter.

    The request host header will still be created from the options parameter.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • options: RequestOptions

    Returns HttpRequest<Buffer>

requestAbs

  • requestAbs(method: HttpMethod, absoluteURI: string): HttpRequest<Buffer>
  • requestAbs(method: HttpMethod, absoluteURI: UriTemplate): HttpRequest<Buffer>
  • requestAbs(method: HttpMethod, serverAddress: SocketAddress, absoluteURI: string): HttpRequest<Buffer>
  • requestAbs(method: HttpMethod, serverAddress: SocketAddress, absoluteURI: UriTemplate): HttpRequest<Buffer>
  • Create an HTTP request to send to the server using an absolute URI

    Parameters

    • method: HttpMethod
    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Create an HTTP request to send to the server using an absolute URI

    Parameters

    • method: HttpMethod
    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#requestAbs} using the serverAddress parameter to connect to the server instead of the absoluteURI parameter.

    The request host header will still be created from the absoluteURI parameter.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • absoluteURI: string

    Returns HttpRequest<Buffer>

  • Like {@link WebClient#requestAbs} using the serverAddress parameter to connect to the server instead of the absoluteURI parameter.

    The request host header will still be created from the absoluteURI parameter.

    Use to connect to a unix domain socket server.

    Parameters

    • method: HttpMethod
    • serverAddress: SocketAddress
    • absoluteURI: UriTemplate

    Returns HttpRequest<Buffer>

Static create

  • Create a session aware web client using the provided webClient instance.

    Parameters

    Returns WebClientSession

  • Create a session aware web client using the provided webClient instance.

    Parameters

    Returns WebClientSession

Static wrap

  • Wrap an httpClient with a web client and default options.

    Parameters

    • httpClient: HttpClient

    Returns WebClient

  • Wrap an httpClient with a web client and default options.

    Only the specific web client portion of the options is used, the HttpClientOptions of the httpClient is reused.

    Parameters

    Returns WebClient

Generated using TypeDoc