Revision 0a4b9bd3

b/asi-http-request-with-pithos/Classes/Pithos/ASIPithosAccount.h
42 42
    NSUInteger bytesUsed;
43 43
    NSDate *untilTimestamp;
44 44
    NSMutableDictionary *groups;
45
    NSMutableDictionary *policy;
45 46
    NSMutableDictionary *metadata;
46 47
    NSDate *lastModified;
47 48
}
......
51 52
@property (assign) NSUInteger bytesUsed;
52 53
@property (retain) NSDate *untilTimestamp;
53 54
@property (retain) NSMutableDictionary *groups;
55
@property (retain) NSMutableDictionary *policy;
54 56
@property (retain) NSMutableDictionary *metadata;
55 57
@property (retain) NSDate *lastModified;
56 58

  
b/asi-http-request-with-pithos/Classes/Pithos/ASIPithosAccount.m
37 37
#import "ASIPithosAccount.h"
38 38

  
39 39
@implementation ASIPithosAccount
40
@synthesize name, containerCount, bytesUsed, untilTimestamp, groups, metadata, lastModified;
40
@synthesize name, containerCount, bytesUsed, untilTimestamp, groups, policy, metadata, lastModified;
41 41

  
42 42
+ (id)account {
43 43
	ASIPithosAccount *account = [[[self alloc] init] autorelease];
......
45 45
}
46 46

  
47 47
- (NSString *)description {
48
    return [NSString stringWithFormat:@"name: %@, containerCount: %lu, bytesUsed: %lu, untilTimestamp: %@, groups: %@, metadata: %@, lastModified: %@", 
49
            name, containerCount, bytesUsed, untilTimestamp, groups, metadata, lastModified];
48
    return [NSString stringWithFormat:@"name: %@, containerCount: %lu, bytesUsed: %lu, untilTimestamp: %@, groups: %@, policy: %@, metadata: %@, lastModified: %@", 
49
            name, containerCount, bytesUsed, untilTimestamp, groups, metadata, policy, lastModified];
50 50
}
51 51

  
52 52
- (void) dealloc {
53 53
    [lastModified release];
54 54
    [metadata release];
55
    [policy release];
55 56
    [groups release];
56 57
    [untilTimestamp release];
57 58
	[name release];
b/asi-http-request-with-pithos/Classes/Pithos/ASIPithosAccountRequest.h
44 44

  
45 45
@interface ASIPithosAccountRequest : ASIPithosRequest <NSXMLParserDelegate> {
46 46
    NSMutableDictionary *groups;
47
    NSMutableDictionary *policy;
47 48
    NSMutableDictionary *metadata;
48 49
    
49 50
    NSMutableArray *containers;
......
67 68
- (NSUInteger)bytesUsed;
68 69
- (NSDate *)untilTimestamp;
69 70
- (NSDictionary *)groups;
71
- (NSDictionary *)policy;
70 72
- (NSDictionary *)metadata;
71 73
- (NSDate *)lastModified;
72 74

  
b/asi-http-request-with-pithos/Classes/Pithos/ASIPithosAccountRequest.m
66 66
	[currentContainer release];
67 67
    [containers release];
68 68
    [metadata release];
69
    [policy release];
69 70
    [groups release];
70 71
	[super dealloc];
71 72
}
......
123 124
    return groups;
124 125
}
125 126

  
127
- (NSDictionary *)policy {
128
    if (policy == nil) {
129
        policy = [self getHeadersDictionaryForPrefix:@"X-Account-Policy-"];
130
        [policy retain];
131
    }
132
    return policy;
133
}
134

  
126 135
- (NSDictionary *)metadata {
127 136
    if (metadata == nil) {
128 137
        metadata = [self getHeadersDictionaryForPrefix:@"X-Account-Meta-"];
......
144 153
    account.bytesUsed = [self bytesUsed];
145 154
    account.untilTimestamp = [self untilTimestamp];
146 155
    account.groups = (NSMutableDictionary *)[self groups];
156
    account.policy = (NSMutableDictionary *)[self policy];
147 157
    account.metadata = (NSMutableDictionary *)[self metadata];
148 158
    account.lastModified = [self lastModified];
149 159
    return account;
b/asi-http-request-with-pithos/Classes/Pithos/ASIPithosObjectRequest.h
133 133
+ (id)objectDataRequestWithContainerName:(NSString *)containerName objectName:(NSString *)objectName 
134 134
                                 version:(NSString *)version 
135 135
                         ifUnmodifiedSince:(NSDate *)sinceTimestamp;
136
// GET storageURL/container/object?[version=version] [Range [If-Range]]
136
// GET storageURL/container/object?[version=version] [Range]
137 137
+ (id)objectDataRequestWithContainerName:(NSString *)containerName objectName:(NSString *)objectName 
138 138
                                 version:(NSString *)version 
139 139
                                   range:(NSString *)rangeString;
140
// GET storageURL/container/object?[version=version] [Range [If-Range]]
140 141
+ (id)objectDataRequestWithContainerName:(NSString *)containerName objectName:(NSString *)objectName 
141 142
                                 version:(NSString *)version 
142 143
                                   range:(NSString *)rangeString 
......
145 146
                                 version:(NSString *)version 
146 147
                                   range:(NSString *)rangeString 
147 148
                        ifRangeTimestamp:(NSDate *)rangeTimestamp;
149
// GET storageURL/container/object?[version=version] [Range] [If-Match]
150
+ (id)objectDataRequestWithContainerName:(NSString *)containerName objectName:(NSString *)objectName 
151
                                 version:(NSString *)version 
152
                                   range:(NSString *)rangeString 
153
                                 ifMatch:(NSString *)matchETag;
154
// GET storageURL/container/object?[version=version] [Range] [If-None-Match]
155
+ (id)objectDataRequestWithContainerName:(NSString *)containerName objectName:(NSString *)objectName 
156
                                 version:(NSString *)version 
157
                                   range:(NSString *)rangeString 
158
                             ifNoneMatch:(NSString *)matchETag;
148 159

  
149 160
- (NSData *)data;
150 161

  
b/asi-http-request-with-pithos/Classes/Pithos/ASIPithosObjectRequest.m
357 357
    return request;
358 358
}
359 359

  
360
// GET storageURL/container/object?[version=version] [Range [If-Range]]
360 361
+ (id)objectDataRequestWithContainerName:(NSString *)containerName objectName:(NSString *)objectName 
361 362
                                 version:(NSString *)version 
362 363
                                   range:(NSString *)rangeString 
......
375 376
    return request;
376 377
}
377 378

  
379
// GET storageURL/container/object?[version=version] [Range] [If-Match]
380
+ (id)objectDataRequestWithContainerName:(NSString *)containerName objectName:(NSString *)objectName 
381
                                 version:(NSString *)version 
382
                                   range:(NSString *)rangeString 
383
                                 ifMatch:(NSString *)matchETag {
384
    ASIPithosObjectRequest *request = [self objectDataRequestWithContainerName:containerName objectName:objectName version:version];
385
    [request addRequestRangeHeader:rangeString];
386
    [request addRequestIfMatchHeader:matchETag];
387
    return request;    
388
}
389

  
390
// GET storageURL/container/object?[version=version] [Range] [If-None-Match]
391
+ (id)objectDataRequestWithContainerName:(NSString *)containerName objectName:(NSString *)objectName 
392
                                 version:(NSString *)version 
393
                                   range:(NSString *)rangeString 
394
                             ifNoneMatch:(NSString *)matchETag {
395
    ASIPithosObjectRequest *request = [self objectDataRequestWithContainerName:containerName objectName:objectName version:version];
396
    [request addRequestRangeHeader:rangeString];
397
    [request addRequestIfNoneMatchHeader:matchETag];
398
    return request;
399
}
400

  
378 401
- (NSData *)data {
379 402
    return [self responseData];
380 403
}
b/asi-http-request-with-pithos/Classes/Pithos/ASIPithosRequest.m
295 295
                [threadDict setObject:dateFormatter forKey:dateFormatterKey];
296 296
                break;
297 297
            case 1:
298
                // date format: Wed, 20 Jul 2011 13:39:19 GMT
298
                // date to format (RFC 1123): Sun, 06 Nov 1994 08:49:37 GMT
299 299
                // Needed for reading X-Account-Until-Timestamp, Last-Modified
300
                // and writing If-Modified-Since, If-Unmodified-Since in the request headers
300 301
                dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
301
                [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
302
                [dateFormatter setDateFormat:@"eee, dd MMM yyyy HH:mm:ss zzz"];
303
                [threadDict setObject:dateFormatter forKey:dateFormatterKey];
304
                break;
305
            case 2:
306
                // date to format: Thu Jul 21 10:54:45 2010
307
                // Can be used to write If-Modified-Since, If-Unmodified-Since in the request headers
308
                dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
309
                [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease]];
310
                [dateFormatter setDateFormat:@"eee MMM dd HH:mm:ss yyyy"];
302
                [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
303
                [dateFormatter setDateFormat:@"eee, dd MMM yyyy HH:mm:ss 'GMT'"];
311 304
                [threadDict setObject:dateFormatter forKey:dateFormatterKey];
312 305
                break;
313 306
            default:
......
322 315

  
323 316
- (void)addRequestIfModifiedSinceHeader:(NSDate *)sinceTimestamp {
324 317
    if (sinceTimestamp)
325
        [self addRequestHeader:@"If-Modified-Since" value:[[self dateFormatterWithFormatId:2] stringFromDate:sinceTimestamp]];        
318
        [self addRequestHeader:@"If-Modified-Since" value:[[self dateFormatterWithFormatId:1] stringFromDate:sinceTimestamp]];        
326 319
}
327 320

  
328 321
- (void)addRequestIfUnmodifiedSinceHeader:(NSDate *)sinceTimestamp {
329 322
    if (sinceTimestamp)
330
        [self addRequestHeader:@"If-Unmodified-Since" value:[[self dateFormatterWithFormatId:2] stringFromDate:sinceTimestamp]];
323
        [self addRequestHeader:@"If-Unmodified-Since" value:[[self dateFormatterWithFormatId:1] stringFromDate:sinceTimestamp]];
331 324
}
332 325

  
333 326
- (void)addRequestIfMatchHeader:(NSString *)matchETag {
......
357 350
    if (rangeString) {
358 351
        [self addRequestHeader:@"Range" value:rangeString];
359 352
        if (rangeTimestamp)
360
            [self addRequestHeader:@"If-Range" value:[[self dateFormatterWithFormatId:2] stringFromDate:rangeTimestamp]];
353
            [self addRequestHeader:@"If-Range" value:[[self dateFormatterWithFormatId:1] stringFromDate:rangeTimestamp]];
361 354
    }
362 355
}
363 356

  

Also available in: Unified diff