35 @synthesize site = _site;
36 @synthesize format = _format;
40 #pragma mark Initialisers
49 [
self setTimeout:60.0];
54 - (id)initWithSite:(NSURL *)site format:(
id<
ARFormat>)format
60 [
self setFormat:format];
65 - (id)initWithSite:(NSURL *)site
78 switch ([response code])
115 if (200 <= [response code] && [response code] < 400)
119 else if (401 <= [response code] && [response code] < 500)
123 else if (500 <= [response code] && [response code] < 600)
133 if (errorCode !=
' ')
135 NSString *localizedDescription = [NSHTTPURLResponse localizedStringForStatusCode:[response
code]];
136 NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:response, ARConnectionHTTPResponseKey, localizedDescription, NSLocalizedDescriptionKey, nil];
137 error = [NSError errorWithDomain:ARConnectionErrorDomain code:errorCode userInfo:userInfo];
147 #pragma mark Building Requests
150 - (NSMutableURLRequest *)requestForHTTPMethod:(NSString *)HTTPMethod path:(NSString *)path headers:(NSDictionary *)headers
152 NSURL *URL = [NSURL URLWithString:path relativeToURL:[
self site]];
153 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:[
self timeout]];
154 NSMutableDictionary *headerFields = [NSMutableDictionary dictionaryWithDictionary:[request allHTTPHeaderFields]];
156 [request setAllHTTPHeaderFields:headerFields];
157 [request setHTTPMethod:HTTPMethod];