NSURLRequest
NSURLRequest 表示一个不可变的 URL 请求。通常在插件里用于读取请求信息,或作为 NSMutableURLRequest 的父接口使用。
类成员 (Class members)
Section titled “类成员 (Class members)”requestWithURL
Section titled “requestWithURL”从 URL 创建请求。
static requestWithURL(URL: NSURL): NSURLRequestParameters:
| Name | Type | Description |
|---|---|---|
URL | NSURL | 请求 URL。 |
Return Value:
NSURLRequest: 新请求实例。
requestWithURLCachePolicyTimeoutInterval
Section titled “requestWithURLCachePolicyTimeoutInterval”从 URL、缓存策略与超时创建请求。
static requestWithURLCachePolicyTimeoutInterval(URL: NSURL, cachePolicy: number, timeoutInterval: number): NSURLRequestParameters:
| Name | Type | Description |
|---|---|---|
URL | NSURL | 请求 URL。 |
cachePolicy | number | 缓存策略。 |
timeoutInterval | number | 超时时间(秒)。 |
Return Value:
NSURLRequest: 新请求实例。
supportsSecureCoding
Section titled “supportsSecureCoding”是否支持安全编码。
static supportsSecureCoding(): booleanReturn Value:
boolean: 是否支持。
实例成员 (Instance members)
Section titled “实例成员 (Instance members)”请求 URL。
URL(): NSURLReturn Value:
NSURL: 请求 URL。
cachePolicy
Section titled “cachePolicy”缓存策略。
cachePolicy(): numberReturn Value:
number: 缓存策略。
timeoutInterval
Section titled “timeoutInterval”超时时间(秒)。
timeoutInterval(): numberReturn Value:
number: 超时时间。
mainDocumentURL
Section titled “mainDocumentURL”主文档 URL。
mainDocumentURL(): NSURLReturn Value:
NSURL: 主文档 URL。
networkServiceType
Section titled “networkServiceType”网络服务类型。
networkServiceType(): numberReturn Value:
number: 服务类型。
allowsCellularAccess
Section titled “allowsCellularAccess”是否允许蜂窝网络。
allowsCellularAccess(): booleanReturn Value:
boolean: 是否允许。
HTTPMethod
Section titled “HTTPMethod”HTTP 方法(如 GET、POST)。
HTTPMethod(): stringReturn Value:
string: 方法名。
allHTTPHeaderFields
Section titled “allHTTPHeaderFields”所有 HTTP 头。
allHTTPHeaderFields(): NSDictionaryReturn Value:
NSDictionary: 头字段字典。
valueForHTTPHeaderField
Section titled “valueForHTTPHeaderField”指定头字段值。
valueForHTTPHeaderField(field: string): stringParameters:
| Name | Type | Description |
|---|---|---|
field | string | 头字段名。 |
Return Value:
string: 头字段值。
HTTPBody
Section titled “HTTPBody”请求体数据。
HTTPBody(): NSDataReturn Value:
NSData: 请求体。
HTTPBodyStream
Section titled “HTTPBodyStream”请求体流。
HTTPBodyStream(): anyReturn Value:
any: 流对象。
HTTPShouldHandleCookies
Section titled “HTTPShouldHandleCookies”是否自动处理 Cookie。
HTTPShouldHandleCookies(): booleanReturn Value:
boolean: 是否处理。
HTTPShouldUsePipelining
Section titled “HTTPShouldUsePipelining”是否使用 HTTP 管道。
HTTPShouldUsePipelining(): booleanReturn Value:
boolean: 是否使用。
建议:需要设置 method/header/body 等可变字段时,直接使用 NSMutableURLRequest。