Freigeben über


BrowserPolicy class

BrowserPolicy will handle differences between Node.js and browser runtime, including:

  1. Browsers cache GET/HEAD requests by adding conditional headers such as 'IF_MODIFIED_SINCE'. BrowserPolicy is a policy used to add a timestamp query to GET/HEAD request URL thus avoid the browser cache.

  2. Remove cookie header for security

  3. Remove content-length header to avoid browsers warning

Extends

BaseRequestPolicy

Constructors

BrowserPolicy(RequestPolicy, RequestPolicyOptions)

Creates an instance of BrowserPolicy.

Methods

log(HttpPipelineLogLevel, string)

Attempt to log the provided message to the provided logger. If no logger was provided or if the log level does not meat the logger's threshold, then nothing will be logged.

sendRequest(WebResource)

Sends out request.

shouldLog(HttpPipelineLogLevel)

Get whether or not a log with the provided log level should be logged.

Constructor Details

BrowserPolicy(RequestPolicy, RequestPolicyOptions)

Creates an instance of BrowserPolicy.

new BrowserPolicy(nextPolicy: RequestPolicy, options: RequestPolicyOptions)

Parameters

nextPolicy

RequestPolicy

options

RequestPolicyOptions

Method Details

log(HttpPipelineLogLevel, string)

Attempt to log the provided message to the provided logger. If no logger was provided or if the log level does not meat the logger's threshold, then nothing will be logged.

function log(logLevel: HttpPipelineLogLevel, message: string)

Parameters

logLevel

HttpPipelineLogLevel

The log level of this log.

message

string

The message of this log.

sendRequest(WebResource)

Sends out request.

function sendRequest(request: WebResource)

Parameters

request

WebResource

Returns

Promise<HttpOperationResponse>

shouldLog(HttpPipelineLogLevel)

Get whether or not a log with the provided log level should be logged.

function shouldLog(logLevel: HttpPipelineLogLevel)

Parameters

logLevel

HttpPipelineLogLevel

The log level of the log that will be logged.

Returns

boolean

Whether or not a log with the provided log level should be logged.