24 @
typedef CPURLRequestCachePolicy
44 BOOL _withCredentials;
47 CPTimeInterval _timeoutInterval;
48 CPURLRequestCachePolicy _cachePolicy;
56 + (id)requestWithURL:(
CPURL)aURL
68 + (id)requestWithURL:(
CPURL)anURL cachePolicy:(CPURLRequestCachePolicy)aCachePolicy timeoutInterval:(CPTimeInterval)aTimeoutInterval
89 - (id)initWithURL:(
CPURL)anURL cachePolicy:(CPURLRequestCachePolicy)aCachePolicy timeoutInterval:(CPTimeInterval)aTimeoutInterval
91 if (
self = [
self initWithURL:anURL])
93 _cachePolicy = aCachePolicy;
94 _timeoutInterval = aTimeoutInterval;
96 [
self _updateCacheControlHeader];
110 if (
self = [super
init])
115 _HTTPMethod =
@"GET";
116 _HTTPHeaderFields = @{};
117 _withCredentials = NO;
118 _timeoutInterval = 60.0;
123 [
self _updateCacheControlHeader];
136 _URL =
new CFURL(aURL);
145 return [_HTTPHeaderFields objectForKey:aField];
155 [_HTTPHeaderFields setObject:aValue forKey:aField];
161 - (void)_updateCacheControlHeader
163 switch (_cachePolicy)
167 [
self setValue:"no-cache" forHTTPHeaderField:"Cache-Control"];
171 [
self setValue:"max-stale=31536000" forHTTPHeaderField:"Cache-Control"];
175 [
self setValue:"only-if-cached" forHTTPHeaderField:"Cache-Control"];
179 [
self setValue:"no-cache" forHTTPHeaderField:"Cache-Control"];
183 [
self setValue:"no-cache" forHTTPHeaderField:"Cache-Control"];
199 [request setHTTPBody:[
self HTTPBody]];
256 _HTTPMethod = aValue;
262 - (BOOL)withCredentials
264 return _withCredentials;
270 - (void)setWithCredentials:(BOOL)aValue
272 _withCredentials = aValue;
280 return _HTTPHeaderFields;
286 - (CPTimeInterval)timeoutInterval
288 return _timeoutInterval;
294 - (CPURLRequestCachePolicy)cachePolicy
id initWithURL:(CPURL aURL)
CPURLRequestCachePolicy CPURLRequestUseProtocolCachePolicy
A mutable key-value pair collection.
id initWithURL:cachePolicy:timeoutInterval:(CPURL anURL, [cachePolicy] CPURLRequestCachePolicy aCachePolicy, [timeoutInterval] CPTimeInterval aTimeoutInterval)
An immutable string (collection of characters).
CPURLRequestReturnCacheDataElseLoad
void setValue:forHTTPHeaderField:(CPString aValue, [forHTTPHeaderField] CPString aField)
CPURLRequestReturnCacheDataDontLoad
CPDictionary allHTTPHeaderFields()
Contains data obtained during a request made with CPURLConnection.
CPURLRequestReloadIgnoringLocalCacheData