API参考Foundation

NSURLRequest

不可变 URL 请求对象,包含 URL、缓存策略、HTTP header/body 等只读访问。

NSURLRequest 表示一个不可变的 URL 请求。默认在插件里用于读取请求信息,或作为 NSMutableURLRequest 的父接口使用。

类成员 (Class members)

requestWithURL

从 URL 创建请求。

static requestWithURL(URL: NSURL): NSURLRequest

Parameters:

NameTypeDescription
URLNSURL请求 URL。

Return Value:

  • NSURLRequest: 新请求实例。

requestWithURLCachePolicyTimeoutInterval

从 URL、缓存策略与超时创建请求。

static requestWithURLCachePolicyTimeoutInterval(URL: NSURL, cachePolicy: number, timeoutInterval: number): NSURLRequest

Parameters:

NameTypeDescription
URLNSURL请求 URL。
cachePolicynumber缓存策略。
timeoutIntervalnumber超时时间(秒)。

Return Value:

  • NSURLRequest: 新请求实例。

supportsSecureCoding

是否支持安全编码。

static supportsSecureCoding(): boolean

Return Value:

  • boolean: 是否支持。

实例成员 (Instance members)

URL

请求 URL。

URL(): NSURL

Return Value:

  • NSURL: 请求 URL。

cachePolicy

缓存策略。

cachePolicy(): number

Return Value:

  • number: 缓存策略。

timeoutInterval

超时时间(秒)。

timeoutInterval(): number

Return Value:

  • number: 超时时间。

mainDocumentURL

主文档 URL。

mainDocumentURL(): NSURL

Return Value:

  • NSURL: 主文档 URL。

networkServiceType

网络服务类型。

networkServiceType(): number

Return Value:

  • number: 服务类型。

allowsCellularAccess

是否允许蜂窝网络。

allowsCellularAccess(): boolean

Return Value:

  • boolean: 是否允许。

HTTPMethod

HTTP 方法(如 GET、POST)。

HTTPMethod(): string

Return Value:

  • string: 方法名。

allHTTPHeaderFields

所有 HTTP 头。

allHTTPHeaderFields(): NSDictionary

Return Value:

  • NSDictionary: 头字段字典。

valueForHTTPHeaderField

指定头字段值。

valueForHTTPHeaderField(field: string): string

Parameters:

NameTypeDescription
fieldstring头字段名。

Return Value:

  • string: 头字段值。

HTTPBody

请求体数据。

HTTPBody(): NSData

Return Value:

  • NSData: 请求体。

HTTPBodyStream

请求体流。

HTTPBodyStream(): any

Return Value:

  • any: 流对象。

HTTPShouldHandleCookies

是否自动处理 Cookie。

HTTPShouldHandleCookies(): boolean

Return Value:

  • boolean: 是否处理。

HTTPShouldUsePipelining

是否使用 HTTP 管道。

HTTPShouldUsePipelining(): boolean

Return Value:

  • boolean: 是否使用。

要求:需要设置 method/header/body 等可变字段时,直接使用 NSMutableURLRequest

头文件API清单

正在加载...

协议:JSBNSURLRequest,来源:-