JsHttpSession class final

可由多个 Fetch/XHR 请求复用的宿主网络会话。

调用方拥有会话生命周期;不再使用时必须调用 close。Cookie Jar 后续可以在此边界 以可选能力加入,不改变 JavaScript Fetch API。

Constructors

JsHttpSession({Client? client, Set<String>? allowedOrigins, Duration timeout = const Duration(seconds: 30), int maxRequestBytes = 1024 * 1024, int maxResponseBytes = 10 * 1024 * 1024, int maxRedirects = 5, Map<String, String> defaultHeaders = const <String, String>{}})
创建可共享的 HTTP 会话,并配置来源白名单和资源限制。

Properties

allowedOrigins Set<String>?
允许访问的规范化 HTTP(S) origin;null 表示不限制。
final
defaultHeaders Map<String, String>
合并到每次请求且可被 JavaScript 覆盖的默认 Header。
final
hashCode int
The hash code for this object.
no setterinherited
isClosed bool
会话是否已经关闭。
no setter
maxRedirects int
单次请求允许跟随的最大重定向次数。
final
maxRequestBytes int
编码后请求体允许的最大字节数。
final
maxResponseBytes int
流式响应体允许的最大字节数。
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeout Duration
请求头与响应体读取的最大持续时间。
final

Methods

close() → void
关闭底层客户端;重复调用没有副作用。
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited