Skip to content

Commit

Permalink
Merged mattrajca#10
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeabdullah authored and mattrajca committed May 20, 2012
1 parent ed2f994 commit a16a01a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Sources/Core/DAVRequests.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@
@interface DAVPutRequest : DAVRequest {
@private
NSData *_pdata;
NSString *_MIMEType;
}

// Pass - [NSData dataWithContentsOfFile:] to upload a local file
@property (strong) NSData *data;
@property (copy) NSString *dataMIMEType; // defaults to application/octet-stream

@end
12 changes: 10 additions & 2 deletions Sources/Core/DAVRequests.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,25 @@ - (NSString *)method {

@implementation DAVPutRequest

- (id)initWithPath:(NSString *)path {
if ((self = [super initWithPath:path])) {
self.dataMIMEType = @"application/octet-stream";
}
return self;
}

@synthesize data = _pdata;
@synthesize dataMIMEType = _MIMEType;

- (NSURLRequest *)request {
NSParameterAssert(_pdata != nil);

NSString *len = [NSString stringWithFormat:@"%ld", [_pdata length]];

NSMutableURLRequest *req = [self newRequestWithPath:self.path method:@"PUT"];
[req setValue:@"application/octet-stream" forHTTPHeaderField:@"Content-Type"];
[req setValue:[self dataMIMEType] forHTTPHeaderField:@"Content-Type"];
[req setValue:len forHTTPHeaderField:@"Content-Length"];
[req setHTTPBody:_pdata];
[req setHTTPBody:_pdata];

return req;
}
Expand Down

0 comments on commit a16a01a

Please sign in to comment.