Skip to content

NSHTTPURLResponse

NSHTTPURLResponseNSURLResponse 的 HTTP 子类,提供 HTTP 状态码与响应头信息。常见于 NSURLConnection 请求回调的 response 参数类型。

返回状态码的本地化描述。

static localizedStringForStatusCode(statusCode: number): string

Parameters:

NameTypeDescription
statusCodenumberHTTP 状态码。

Return Value:

  • string: 本地化描述。

initWithURLStatusCodeHTTPVersionHeaderFields

Section titled “initWithURLStatusCodeHTTPVersionHeaderFields”

初始化 HTTP 响应实例。

initWithURLStatusCodeHTTPVersionHeaderFields(url: NSURL, statusCode: number, httpVersion: string, headerFields: NSDictionary): void

Parameters:

NameTypeDescription
urlNSURL响应 URL。
statusCodenumberHTTP 状态码。
httpVersionstringHTTP 版本。
headerFieldsNSDictionary响应头字典。

Return Value:

  • 无。

HTTP 状态码。

statusCode(): number

Return Value:

  • number: 状态码(如 200、404)。

所有响应头。

allHeaderFields(): NSDictionary

Return Value:

  • NSDictionary: 头字段字典。
头文件 API 清单

正在加载…

协议:,来源: