Revision 62ea6d49 Classes/OpenStackRequest.m

b/Classes/OpenStackRequest.m
20 20

  
21 21
@implementation OpenStackRequest
22 22

  
23
@synthesize account, callback, errorAlerter, retryWithUpdatedURL, followUpSelectorString, notificationURL;
23
@synthesize account, callback, errorAlerter, retryWithUpdatedURL, retryBaseURL, retryType, followUpSelectorString, notificationURL;
24 24

  
25 25
#pragma mark - Constructors
26 26
#pragma mark Generic
......
33 33
    request.timeOutSeconds = 60;
34 34
    request.numberOfTimesToRetryOnTimeout = 5;
35 35
    request.validatesSecureCertificate = !account.ignoreSSLErrors;
36
    request.retryWithUpdatedURL = (account.provider.manual ? NO : YES);
36
    request.retryWithUpdatedURL = NO;
37 37
	return request;
38 38
}
39 39

  
40 40
+ (id)request:(OpenStackAccount *)account method:(NSString *)method url:(NSURL *)url {
41 41
	OpenStackRequest *request = [self requestWithoutToken:account method:method url:url];
42
    request.retryWithUpdatedURL = (account.provider.manual ? NO : YES);
42 43
	[request addRequestHeader:@"X-Auth-Token" value:account.authToken];
43 44
	return request;
44 45
}
45 46

  
46 47
+ (id)filesRequest:(OpenStackAccount *)account method:(NSString *)method path:(NSString *)path {
47
    NSString *urlString = [account.filesURL description];
48
    if (account.sharingAccount) {
49
        urlString = [NSString stringWithFormat:@"%@%@",
50
                     [urlString substringToIndex:[urlString rangeOfString:account.username].location],
51
                     account.sharingAccount];
52
    }
48
    NSString *urlString = [[account.provider.authEndpointURL
49
                            URLByAppendingPathComponent:(account.sharingAccount ? account.sharingAccount : account.username)] description];
53 50
	NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@?format=json%@",
54 51
                                       urlString,
55 52
                                       path,
56 53
                                       (account.shared ? @"&shared=" : @"")]];
57
    return [self request:account method:method url:url];
54
    OpenStackRequest *request = [self request:account method:method url:url];
55
    request.retryBaseURL = account.provider.authEndpointURL;
56
    request.retryType = OpenStackRequestTypeAuthEndpoint;
57
    return request;
58 58
}
59 59

  
60 60
#pragma mark NSCopying
......
65 65
    newRequest.callback = self.callback;
66 66
    newRequest.errorAlerter = self.errorAlerter;
67 67
    newRequest.retryWithUpdatedURL = self.retryWithUpdatedURL;
68
    newRequest.retryBaseURL = self.retryBaseURL;
69
    newRequest.retryType = self.retryType;
68 70
    newRequest.followUpSelectorString = self.followUpSelectorString;
69 71
    newRequest.notificationURL = self.notificationURL;
70 72
    return newRequest;
......
100 102
#pragma mark User Catalog
101 103
+ (id)userCatalogRequest:(OpenStackAccount *)account displaynames:(NSArray *)displaynames UUIDs:(NSArray *)UUIDs {
102 104
    OpenStackRequest *request = [self request:account method:@"POST" url:account.provider.userCatalogURL];
105
    request.retryBaseURL = account.provider.userCatalogURL;
106
    request.retryType = OpenStackRequestTypeUserCatalog;
103 107
    NSMutableString *dataString = [NSMutableString stringWithString:@"{\"displaynames\":["];
104 108
    if (displaynames) {
105 109
        for (NSUInteger index = 0 ; index < displaynames.count ; index++) {
......
146 150
    request.numberOfTimesToRetryOnTimeout = 5;
147 151
    request.validatesSecureCertificate = !account.ignoreSSLErrors;
148 152
    request.retryWithUpdatedURL = (account.provider.manual ? NO : YES);
153
    request.retryBaseURL = account.provider.authEndpointURL;
154
    request.retryType = OpenStackRequestTypeAuthEndpoint;
149 155
	return request;
150 156
}
151 157

  
......
154 160
    OpenStackRequest *request = [self request:account method:@"GET"
155 161
                                          url:[NSURL URLWithString:[NSString stringWithFormat:@"%@?format=json",
156 162
                                                                    account.provider.authEndpointURL]]];
163
    request.retryBaseURL = account.provider.authEndpointURL;
164
    request.retryType = OpenStackRequestTypeAuthEndpoint;
157 165
    if (marker)
158 166
        request.url = [NSURL URLWithString:[NSString stringWithFormat:@"%@&marker=%@", request.url.description, [NSString encodeToPercentEscape:marker]]];
159 167
    if (!sharingAccountsBuffer)
......
456 464
- (void)dealloc {
457 465
    [account release];
458 466
    [errorAlerter release];
467
    [retryBaseURL release];
459 468
    [followUpSelectorString release];
460 469
    [notificationURL release];
461 470
    [self releaseBackupBlocksOnMainThread];

Also available in: Unified diff