你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

WebResource class

创建新的 WebResource 对象。

此类通过与库/实现无关并包装启动请求所需的属性来对 REST 调用进行抽象。

构造函数

WebResource(string, HttpMethods, any, {[key: string]: any}, {[key: string]: any} | HttpHeadersLike, boolean, boolean, AbortSignalLike, number, (progress: TransferProgressEvent) => void, (progress: TransferProgressEvent) => void, ProxySettings, boolean, AgentSettings, number)

属性

abortSignal
agentSettings
body
formData
headers
keepAlive
method
onDownloadProgress

下载进度时触发的回调。

onUploadProgress

上传进度时触发的回调。

operationResponseGetter

一个函数,该函数返回给定 OperationSpec 和 HttpOperationResponse 组合的正确 OperationResponse。 如果未定义,则使用简单的状态代码查找。

operationSpec
proxySettings
query
redirectLimit
shouldDeserialize

是否应反序列化 HttpOperationResponse。 如果未定义,则应反序列化 HttpOperationResponse。

streamResponseBody

是否应将 HttpOperationResponse 的正文视为流。

timeout
url
withCredentials

方法

clone()

克隆此 WebResource HTTP 请求对象。

prepare(RequestPrepareOptions)

准备请求。

validateRequestProperties()

验证是否定义了所需的属性,例如方法、url、标头[“Content-Type”]、headers[“accept-language”] 。 如果未定义上述某个属性,则会引发错误。

构造函数详细信息

WebResource(string, HttpMethods, any, {[key: string]: any}, {[key: string]: any} | HttpHeadersLike, boolean, boolean, AbortSignalLike, number, (progress: TransferProgressEvent) => void, (progress: TransferProgressEvent) => void, ProxySettings, boolean, AgentSettings, number)

new WebResource(url?: string, method?: HttpMethods, body?: any, query?: {[key: string]: any}, headers?: {[key: string]: any} | HttpHeadersLike, streamResponseBody?: boolean, withCredentials?: boolean, abortSignal?: AbortSignalLike, timeout?: number, onUploadProgress?: (progress: TransferProgressEvent) => void, onDownloadProgress?: (progress: TransferProgressEvent) => void, proxySettings?: ProxySettings, keepAlive?: boolean, agentSettings?: AgentSettings, redirectLimit?: number)

参数

url

string

method
HttpMethods
body

any

query

{[key: string]: any}

headers

{[key: string]: any} | HttpHeadersLike

streamResponseBody

boolean

withCredentials

boolean

abortSignal
AbortSignalLike
timeout

number

onUploadProgress

(progress: TransferProgressEvent) => void

onDownloadProgress

(progress: TransferProgressEvent) => void

proxySettings
ProxySettings
keepAlive

boolean

agentSettings
AgentSettings
redirectLimit

number

属性详细信息

abortSignal

abortSignal?: AbortSignalLike

属性值

agentSettings

agentSettings?: AgentSettings

属性值

body

body?: any

属性值

any

formData

formData?: any

属性值

any

headers

headers: HttpHeadersLike

属性值

keepAlive

keepAlive?: boolean

属性值

boolean

method

method: HttpMethods

属性值

onDownloadProgress

下载进度时触发的回调。

onDownloadProgress?: (progress: TransferProgressEvent) => void

属性值

(progress: TransferProgressEvent) => void

onUploadProgress

上传进度时触发的回调。

onUploadProgress?: (progress: TransferProgressEvent) => void

属性值

(progress: TransferProgressEvent) => void

operationResponseGetter

一个函数,该函数返回给定 OperationSpec 和 HttpOperationResponse 组合的正确 OperationResponse。 如果未定义,则使用简单的状态代码查找。

operationResponseGetter?: (operationSpec: OperationSpec, response: HttpOperationResponse) => undefined | OperationResponse

属性值

(operationSpec: OperationSpec, response: HttpOperationResponse) => undefined | OperationResponse

operationSpec

operationSpec?: OperationSpec

属性值

proxySettings

proxySettings?: ProxySettings

属性值

query

query?: {[key: string]: any}

属性值

{[key: string]: any}

redirectLimit

redirectLimit?: number

属性值

number

shouldDeserialize

是否应反序列化 HttpOperationResponse。 如果未定义,则应反序列化 HttpOperationResponse。

shouldDeserialize?: boolean | (response: HttpOperationResponse) => boolean

属性值

boolean | (response: HttpOperationResponse) => boolean

streamResponseBody

是否应将 HttpOperationResponse 的正文视为流。

streamResponseBody?: boolean

属性值

boolean

timeout

timeout: number

属性值

number

url

url: string

属性值

string

withCredentials

withCredentials: boolean

属性值

boolean

方法详细信息

clone()

克隆此 WebResource HTTP 请求对象。

function clone(): WebResource

返回

此 WebResource HTTP 请求对象的克隆。

prepare(RequestPrepareOptions)

准备请求。

function prepare(options: RequestPrepareOptions): WebResource

参数

options
RequestPrepareOptions

用于准备请求的选项。

返回

返回准备好的 WebResource (HTTP 请求) 对象,该对象需要提供给请求管道。

validateRequestProperties()

验证是否定义了所需的属性,例如方法、url、标头[“Content-Type”]、headers[“accept-language”] 。 如果未定义上述某个属性,则会引发错误。

function validateRequestProperties()