xml地图|网站地图|网站标签 [设为首页] [加入收藏]

皇家国际娱乐中心:不要在cookie中使用特殊字符

来源:http://www.ccidsi.com 作者:最新解决方案 人气:61 发布时间:2019-09-19
摘要:Constructs a cookie with a specified name and value. 继承自:NSObject 服从左券:NSObject 导入证明: @import Foundation; 适用范围:iOS 2.0 及今后 The name must conform to RFC 2109. That means it can contain only ASCIIal

Constructs a cookie with a specified name and value.

继承自:NSObject
服从左券:NSObject
导入证明:@import Foundation;
适用范围:iOS 2.0 及今后

The name must conform to RFC 2109. That means it can contain only ASCII alphanumeric characters and cannot contain commas, semicolons, or white space or begin with a $ character. The cookie's name cannot be changed after creation.

一、概述(Overview)

三个 NSHTTPCookie 对象表示多少个 HTTP cookie。NSHTTP库克ie 对象是不可变的,它最初化自叁个含有 cookie 属性的字典。

NSHTTPCookie 类帮助三种分裂的 cookie 版本:

  • 本子 0:这种本子指的是观念的大概过时的 cookie,也正是网景(Netscape)公司定义的开始时期的这种 cookie 格式。大家遭受的大部 cookie 都以这种格式。

  • 本子 1:这种本子指的是这么些在 RFC 2965,HTTP State Management Mechanism 中定义的 cookie。

The value can be anything the server chooses to send. Its value is probably of interest only to the server. The cookie's value can be changed after creation with the setValue method.

二、功能(Tasks)

By default, cookies are created according to the Netscape cookie specification. The version can be changed with the setVersion method.

1.创建 NSHTTPCookie 实例(Create cookie instances)

以上是java API文书档案中对Cookie类构造函数的表明,入眼对name和value能够使用的字符举办了介绍。

cookiesWithResponseHeaderFields:forURL:

Returns an array of NSHTTPCookie objects corresponding to the provided response header fields for the provided URL.

Declaration

  (NSArray <NSHTTPCookie *> *)cookiesWithResponseHeaderFields:(NSDictionary <NSString *,  NSString *> *)*headerFields*
                                                       forURL:(NSURL *)theURL

Parameters

参数 含义
headerFields The header fields used to create the NSHTTPCookie objects.
theURL The URL associated with the created cookies.

Return Value
The array of created cookies.

Discussion
This method ignores irrelevant header fields in headerFields, allowing dictionaries to contain additional data.
If headerFields does not specify a domain for a given cookie, the cookie is created with a default domain value of the URL.
If headerFields does not specify a path for a given cookie, the cookie is created with a default path value of "/".

Availability
Available in iOS 2.0 and later.


参数name必要依照标准奥迪Q5FC2109,也正是说name参数只好分包字母或许数字,不可能包涵逗号、分号、空格及英镑符号。cookie的name属性设置之后不能被修改。

cookieWithProperties:

Creates and initializes an NSHTTPCookie object using the provided properties.

Declaration

  (NSHTTPCookie *)cookieWithProperties:(NSDictionary <NSString *, id> *)properties

Parameters

参数 含义
properties The properties for the new cookie object, expressed as key value pairs.

Return Value
The newly created cookie object. Returns nil if the provided properties are invalid.

Discussion
To successfully create a cookie, you must provide values for (at least) the NSHTTPCookiePath, NSHTTPCookieName, and NSHTTPCookieValue keys, and either the NSHTTPCookieOriginURL key or the NSHTTPCookieDomain key.
See Constants for more information on the available cookie attribute constants and the constraints imposed on the values in the dictionary.

Availability
Available in iOS 2.0 and later.

See Also
– initWithProperties:


- initWithProperties:

Returns an initialized NSHTTPCookie object using the provided properties.

Declaration

- (instancetype)initWithProperties:(NSDictionary <NSString *, id> *)properties

Parameters

参数 含义
properties The properties for the new cookie object, expressed as key value pairs.

Return Value
The initialized cookie object. Returns nil if the provided properties are invalid.

Discussion
To successfully create a cookie, you must provide values for (at least) the NSHTTPCookiePath, NSHTTPCookieName, and NSHTTPCookieValue
keys, and either the NSHTTPCookieOriginURL key or the NSHTTPCookieDomain key.
See Constants for more information on the available cookie attribute constants and the constraints imposed on the values in the dictionary.

Availability
Available in iOS 2.0 and later.

See Also
cookieWithProperties:

参数value能够是服务端设置的放肆值,该值能够通过setValue方法举办复位。

2.将 cookie 转成央求头(Convert cookies to request headers)

requestHeaderFieldsWithCookies:

Returns a dictionary of header fields corresponding to a provided array of cookies.

Declaration

  (NSDictionary)<NSString*, NSString *> *)requestHeaderFieldsWithCookies:(NSArray <NSHTTPCookie *> *)cookies

Parameters

参数 含义
cookies The cookies from which the header fields are created.

Return Value
The dictionary of header fields created from the provided cookies.

Discussion
To send these headers as part of a URL request to a remote server, create an NSMutableURLRequest object, then call the setAllHTTPHeaderFields: or setValue:forHTTPHeaderField: method to set the provided headers for the request. Finally, initialize and start an NSURLSessionTask, NSURLConnection, or NSURLDownload object based on that request object.

Availability
Available in iOS 2.0 and later.

本文由68399皇家赌场发布于最新解决方案,转载请注明出处:皇家国际娱乐中心:不要在cookie中使用特殊字符

关键词: 68399皇家赌场 征服iOS 技术文献翻译

最火资讯