NSHTTPURLResponse
NSHTTPURLResponse 是 NSURLResponse 的 HTTP 子类,提供 HTTP 状态码与响应头信息。常见于 NSURLConnection 请求回调的 response 参数类型。
类成员 (Class members)
Section titled “类成员 (Class members)”localizedStringForStatusCode
Section titled “localizedStringForStatusCode”返回状态码的本地化描述。
static localizedStringForStatusCode(statusCode: number): stringParameters:
| Name | Type | Description |
|---|---|---|
statusCode | number | HTTP 状态码。 |
Return Value:
string: 本地化描述。
实例成员 (Instance members)
Section titled “实例成员 (Instance members)”initWithURLStatusCodeHTTPVersionHeaderFields
Section titled “initWithURLStatusCodeHTTPVersionHeaderFields”初始化 HTTP 响应实例。
initWithURLStatusCodeHTTPVersionHeaderFields(url: NSURL, statusCode: number, httpVersion: string, headerFields: NSDictionary): voidParameters:
| Name | Type | Description |
|---|---|---|
url | NSURL | 响应 URL。 |
statusCode | number | HTTP 状态码。 |
httpVersion | string | HTTP 版本。 |
headerFields | NSDictionary | 响应头字典。 |
Return Value:
- 无。
statusCode
Section titled “statusCode”HTTP 状态码。
statusCode(): numberReturn Value:
number: 状态码(如 200、404)。
allHeaderFields
Section titled “allHeaderFields”所有响应头。
allHeaderFields(): NSDictionaryReturn Value:
NSDictionary: 头字段字典。