Share via


@azure/core-https package

Classes

DefaultHttpsClient

A HttpsClient implementation that uses Node's "https" module to send HTTPS requests.

RestError

A custom error type for failed pipeline requests.

Interfaces

AddPipelineOptions

Options when adding a policy to the pipeline. Used to express dependencies on other policies.

BearerTokenAuthenticationPolicyOptions

Options to configure the bearerTokenAuthenticationPolicy

ExponentialRetryPolicyOptions

Options that control how to retry failed requests.

HttpHeaders

Represents a set of HTTP headers on a request/response. Header names are treated as case insensitive.

HttpsClient

The required interface for a client that makes HTTPS requests on behalf of a pipeline.

InternalPipelineOptions

Defines options that are used to configure internal options of the HTTP pipeline for an SDK client.

LogPolicyOptions

Options to configure the logPolicy.

Pipeline

Represents a pipeline for making a HTTPS request to a URL. Pipelines can have multiple policies to manage manipulating each request before and after it is made to the server.

PipelineOptions

Defines options that are used to configure the HTTP pipeline for an SDK client.

PipelinePolicy

A pipeline policy manipulates a request as it travels through the pipeline. It is conceptually a middleware that is allowed to modify the request before it is made as well as the response when it is received.

PipelineRequest

Metadata about a request being made by the pipeline.

PipelineRequestOptions

Settings to initialize a request. Almost equivalent to Partial<PipelineRequest>, but url is mandatory.

PipelineResponse

Metadata about a response received by the pipeline.

ProxySettings

Options to configure a proxy for outgoing requests (Node.js only).

RedirectPolicyOptions

Options for how redirect responses are handled.

RestErrorOptions

The options supported by RestError.

SystemErrorRetryPolicyOptions

Options that control how to retry failed requests.

TracingPolicyOptions

Options to configure the tracing policy.

UserAgentPolicyOptions

Options for adding user agent details to outgoing requests.

Type Aliases

FormDataMap

A simple object that provides form data, as if from a browser form.

FormDataValue

Each form data entry can be a string or (in the browser) a Blob.

HttpMethods

Supported HTTP methods to use when making requests.

PipelinePhase

Policies are executed in phases. The execution order is:

  1. Serialize Phase
  2. Policies not in a phase
  3. Deserialize Phase
  4. Retry Phase
RawHttpHeaders

A HttpHeaders collection represented as a simple JSON object.

RequestBodyType

Types of bodies supported on the request. NodeJS.ReadableStream is Node only. Blob is browser only.

SendRequest

A simple interface for making a pipeline request and receiving a response.

TransferProgressEvent

Fired in response to upload or download progress.

Functions

bearerTokenAuthenticationPolicy(BearerTokenAuthenticationPolicyOptions)

A policy that can request a token from a TokenCredential implementation and then apply it to the Authorization header of a request as a Bearer token.

createEmptyPipeline()

Creates a totally empty pipeline. Useful for testing or creating a custom one.

createHttpHeaders(RawHttpHeaders)

Creates an object that satisfies the HttpHeaders interface.

createPipelineFromOptions(InternalPipelineOptions)

Create a new pipeline with a default set of customizable policies.

createPipelineRequest(PipelineRequestOptions)

Creates a new pipeline request with the given options. This method is to allow for the easy setting of default values and not required.

decompressResponsePolicy()

A policy to enable response decompression according to Accept-Encoding header https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding

exponentialRetryPolicy(ExponentialRetryPolicyOptions)

A policy that attempts to retry requests while introducing an exponentially increasing delay.

formDataPolicy()

A policy that encodes FormData on the request into the body.

getDefaultProxySettings(string)

This method converts a proxy url into ProxySettings for use with ProxyPolicy. If no argument is given, it attempts to parse a proxy URL from the environment variables HTTPS_PROXY or HTTP_PROXY.

logPolicy(LogPolicyOptions)

A policy that logs all requests and responses.

ndJsonPolicy()

ndJsonPolicy is a policy used to control keep alive settings for every request.

proxyPolicy(ProxySettings)

A policy that allows one to apply proxy settings to all requests. If not passed static settings, they will be retrieved from the HTTPS_PROXY or HTTP_PROXY environment variables.

redirectPolicy(RedirectPolicyOptions)

A policy to follow Location headers from the server in order to support server-side redirection.

setClientRequestIdPolicy(string)

Each PipelineRequest gets a unique id upon creation. This policy passes that unique id along via an HTTP header to enable better telemetry and tracing.

systemErrorRetryPolicy(SystemErrorRetryPolicyOptions)

A retry policy that specifically seeks to handle errors in the underlying transport layer (e.g. DNS lookup failures) rather than retryable error codes from the server itself.

throttlingRetryPolicy()

A policy that retries when the server sends a 429 response with a Retry-After header.

To learn more, please refer to https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-request-limits, https://docs.microsoft.com/en-us/azure/azure-subscription-service-limits and https://docs.microsoft.com/en-us/azure/virtual-machines/troubleshooting/troubleshooting-throttling-errors

tracingPolicy(TracingPolicyOptions)

A simple policy to create OpenTelemetry Spans for each request made by the pipeline that has SpanOptions with a parent. Requests made without a parent Span will not be recorded.

userAgentPolicy(UserAgentPolicyOptions)

A policy that sets the User-Agent header (or equivalent) to reflect the library version.

Variables

bearerTokenAuthenticationPolicyName

The programmatic identifier of the bearerTokenAuthenticationPolicy.

decompressResponsePolicyName

The programmatic identifier of the decompressResponsePolicy.

expontentialRetryPolicyName

The programmatic identifier of the exponentialRetryPolicy.

formDataPolicyName

The programmatic identifier of the formDataPolicy.

logPolicyName

The programmatic identifier of the logPolicy.

ndJsonPolicyName

The programmatic identifier of the ndJsonPolicy.

proxyPolicyName

The programmatic identifier of the proxyPolicy.

redirectPolicyName

The programmatic identifier of the redirectPolicy.

setClientRequestIdPolicyName

The programmatic identifier of the setClientRequestIdPolicy.

systemErrorRetryPolicyName

The programmatic identifier of the systemErrorRetryPolicy.

throttlingRetryPolicyName

The programmatic identifier of the throttlingRetryPolicy.

tracingPolicyName

The programmatic identifier of the tracingPolicy.

userAgentPolicyName

The programmatic identifier of the userAgentPolicy.

Function Details

bearerTokenAuthenticationPolicy(BearerTokenAuthenticationPolicyOptions)

A policy that can request a token from a TokenCredential implementation and then apply it to the Authorization header of a request as a Bearer token.

function bearerTokenAuthenticationPolicy(options: BearerTokenAuthenticationPolicyOptions): PipelinePolicy

Parameters

Returns

createEmptyPipeline()

Creates a totally empty pipeline. Useful for testing or creating a custom one.

function createEmptyPipeline(): Pipeline

Returns

createHttpHeaders(RawHttpHeaders)

Creates an object that satisfies the HttpHeaders interface.

function createHttpHeaders(rawHeaders?: RawHttpHeaders): HttpHeaders

Parameters

rawHeaders
RawHttpHeaders

A simple object representing initial headers

Returns

createPipelineFromOptions(InternalPipelineOptions)

Create a new pipeline with a default set of customizable policies.

function createPipelineFromOptions(options: InternalPipelineOptions): Pipeline

Parameters

options
InternalPipelineOptions

Options to configure a custom pipeline.

Returns

createPipelineRequest(PipelineRequestOptions)

Creates a new pipeline request with the given options. This method is to allow for the easy setting of default values and not required.

function createPipelineRequest(options: PipelineRequestOptions): PipelineRequest

Parameters

options
PipelineRequestOptions

The options to create the request with.

Returns

decompressResponsePolicy()

A policy to enable response decompression according to Accept-Encoding header https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding

function decompressResponsePolicy(): PipelinePolicy

Returns

exponentialRetryPolicy(ExponentialRetryPolicyOptions)

A policy that attempts to retry requests while introducing an exponentially increasing delay.

function exponentialRetryPolicy(options?: ExponentialRetryPolicyOptions): PipelinePolicy

Parameters

options
ExponentialRetryPolicyOptions

Options that configure retry logic.

Returns

formDataPolicy()

A policy that encodes FormData on the request into the body.

function formDataPolicy(): PipelinePolicy

Returns

getDefaultProxySettings(string)

This method converts a proxy url into ProxySettings for use with ProxyPolicy. If no argument is given, it attempts to parse a proxy URL from the environment variables HTTPS_PROXY or HTTP_PROXY.

function getDefaultProxySettings(proxyUrl?: string): ProxySettings | undefined

Parameters

proxyUrl

string

The url of the proxy to use. May contain authentication information.

Returns

ProxySettings | undefined

logPolicy(LogPolicyOptions)

A policy that logs all requests and responses.

function logPolicy(options?: LogPolicyOptions): PipelinePolicy

Parameters

options
LogPolicyOptions

Options to configure logPolicy.

Returns

ndJsonPolicy()

ndJsonPolicy is a policy used to control keep alive settings for every request.

function ndJsonPolicy(): PipelinePolicy

Returns

proxyPolicy(ProxySettings)

A policy that allows one to apply proxy settings to all requests. If not passed static settings, they will be retrieved from the HTTPS_PROXY or HTTP_PROXY environment variables.

function proxyPolicy(proxySettings?: ProxySettings): PipelinePolicy

Parameters

proxySettings
ProxySettings

ProxySettings to use on each request.

Returns

redirectPolicy(RedirectPolicyOptions)

A policy to follow Location headers from the server in order to support server-side redirection.

function redirectPolicy(options?: RedirectPolicyOptions): PipelinePolicy

Parameters

options
RedirectPolicyOptions

Options to control policy behavior.

Returns

setClientRequestIdPolicy(string)

Each PipelineRequest gets a unique id upon creation. This policy passes that unique id along via an HTTP header to enable better telemetry and tracing.

function setClientRequestIdPolicy(requestIdHeaderName?: string): PipelinePolicy

Parameters

requestIdHeaderName

string

The name of the header to pass the request ID to.

Returns

systemErrorRetryPolicy(SystemErrorRetryPolicyOptions)

A retry policy that specifically seeks to handle errors in the underlying transport layer (e.g. DNS lookup failures) rather than retryable error codes from the server itself.

function systemErrorRetryPolicy(options?: SystemErrorRetryPolicyOptions): PipelinePolicy

Parameters

options
SystemErrorRetryPolicyOptions

Options that customize the policy.

Returns

throttlingRetryPolicy()

tracingPolicy(TracingPolicyOptions)

A simple policy to create OpenTelemetry Spans for each request made by the pipeline that has SpanOptions with a parent. Requests made without a parent Span will not be recorded.

function tracingPolicy(options?: TracingPolicyOptions): PipelinePolicy

Parameters

options
TracingPolicyOptions

Options to configure the telemetry logged by the tracing policy.

Returns

userAgentPolicy(UserAgentPolicyOptions)

A policy that sets the User-Agent header (or equivalent) to reflect the library version.

function userAgentPolicy(options?: UserAgentPolicyOptions): PipelinePolicy

Parameters

options
UserAgentPolicyOptions

Options to customize the user agent value.

Returns

Variable Details

bearerTokenAuthenticationPolicyName

The programmatic identifier of the bearerTokenAuthenticationPolicy.

bearerTokenAuthenticationPolicyName: "bearerTokenAuthenticationPolicy"

Type

"bearerTokenAuthenticationPolicy"

decompressResponsePolicyName

The programmatic identifier of the decompressResponsePolicy.

decompressResponsePolicyName: "decompressResponsePolicy"

Type

"decompressResponsePolicy"

expontentialRetryPolicyName

The programmatic identifier of the exponentialRetryPolicy.

expontentialRetryPolicyName: "exponentialRetryPolicy"

Type

"exponentialRetryPolicy"

formDataPolicyName

The programmatic identifier of the formDataPolicy.

formDataPolicyName: "formDataPolicy"

Type

"formDataPolicy"

logPolicyName

The programmatic identifier of the logPolicy.

logPolicyName: "logPolicy"

Type

"logPolicy"

ndJsonPolicyName

The programmatic identifier of the ndJsonPolicy.

ndJsonPolicyName: "ndJsonPolicy"

Type

"ndJsonPolicy"

proxyPolicyName

The programmatic identifier of the proxyPolicy.

proxyPolicyName: "proxyPolicy"

Type

"proxyPolicy"

redirectPolicyName

The programmatic identifier of the redirectPolicy.

redirectPolicyName: "redirectPolicy"

Type

"redirectPolicy"

setClientRequestIdPolicyName

The programmatic identifier of the setClientRequestIdPolicy.

setClientRequestIdPolicyName: "setClientRequestIdPolicy"

Type

"setClientRequestIdPolicy"

systemErrorRetryPolicyName

The programmatic identifier of the systemErrorRetryPolicy.

systemErrorRetryPolicyName: "systemErrorRetryPolicy"

Type

"systemErrorRetryPolicy"

throttlingRetryPolicyName

The programmatic identifier of the throttlingRetryPolicy.

throttlingRetryPolicyName: "throttlingRetryPolicy"

Type

"throttlingRetryPolicy"

tracingPolicyName

The programmatic identifier of the tracingPolicy.

tracingPolicyName: "tracingPolicy"

Type

"tracingPolicy"

userAgentPolicyName

The programmatic identifier of the userAgentPolicy.

userAgentPolicyName: "userAgentPolicy"

Type

"userAgentPolicy"