Defined in: http.ts:33
optionalbody?:HttpRequestBody
Defined in: http.ts:36
optionalheaders?:Record<string,string>
Defined in: http.ts:35
optionalmethod?:string
Defined in: http.ts:34
optionalresponseType?:"text"|"json"|"binary"
Defined in: http.ts:40
"text"(默认)| "json" | "binary"。流式请用 fetchStream()。
optionaltimeoutMs?:number
Defined in: http.ts:38
N 毫秒后中止请求。
Defined in: http.ts:8
optionalbinary?:Uint8Array<ArrayBufferLike>
Defined in: http.ts:23
responseType 为 "binary" 时提供(字节)。
body:
string
Defined in: http.ts:12
headers:
Record<string,string>
Defined in: http.ts:11
optionaljson?:unknown
Defined in: http.ts:21
responseType 为 "json" 时提供。
ok:
boolean
Defined in: http.ts:10
status:
number
Defined in: http.ts:9
Defined in: http.ts:77
流式响应:先到 headers,body chunk 随到达逐个给出。
body:
ReadableStream<Uint8Array<ArrayBufferLike>>
Defined in: http.ts:82
以字节流形式提供的响应体(渐进送达)。
headers:
Record<string,string>
Defined in: http.ts:80
ok:
boolean
Defined in: http.ts:79
status:
number
Defined in: http.ts:78
HttpRequestBody =
string|Uint8Array|ArrayBuffer|Record<string,unknown>
Defined in: http.ts:26
consthttp:object
Defined in: http.ts:163
fetch: (
url,options) =>Promise<HttpResponse>
执行一个受作用域约束的 HTTP 请求;URL 超出作用域时抛出异常。
string
FetchOptions = {}
Promise<HttpResponse>
fetchStream: (
url,options) =>Promise<HttpStreamResponse>
执行作用域内的 HTTP 请求,响应体以流交付:status + headers 一到 promise 即 resolve,body 随每个网络 chunk(Uint8Array)到达逐个产出——应用无需缓冲整个响应;流中途出错会让 body 的读取 reject。
string
FetchOptions = {}
Promise<HttpStreamResponse>
fetch(
url,options?):Promise<HttpResponse>
Defined in: http.ts:67
执行一个受作用域约束的 HTTP 请求;URL 超出作用域时抛出异常。
string
FetchOptions = {}
Promise<HttpResponse>
fetchStream(
url,options?):Promise<HttpStreamResponse>
Defined in: http.ts:101
执行作用域内的 HTTP 请求,响应体以流交付:status + headers 一到 promise 即 resolve,body 随每个网络 chunk(Uint8Array)到达逐个产出——应用无需缓冲整个响应;流中途出错会让 body 的读取 reject。
string
FetchOptions = {}
Promise<HttpStreamResponse>