Skip to content

Commit

Permalink
Allow user to pass custom cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
ascorbic committed Jan 20, 2011
1 parent 2bc361d commit 344d5da
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions iPhone/FileUploader/FileUploader.m
Expand Up @@ -102,16 +102,22 @@ - (void) uploadFile:(NSURL*)file toServer:(NSString*)server withParams:(NSMutabl
if(!fileKey) {
fileKey = @"file";
}

NSString *boundary = @"*****com.beetight.formBoundary";

NSURL *url = [NSURL URLWithString:server];

NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
[req setHTTPMethod:@"POST"];

if([params objectForKey:@"__cookie"]) {
[req setValue:[params objectForKey:@"__cookie"] forHTTPHeaderField:@"Cookie"];
[params removeObjectForKey:@"__cookie"];
[req setHTTPShouldHandleCookies:NO];
}

NSString *boundary = @"*****com.beetight.formBoundary";

NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[req setValue:contentType forHTTPHeaderField:@"Content-type"];
[req setValue:@"XMLHttpRequest" forHTTPHeaderField:@"X-Requested-With"];
NSString* userAgent = [[webView request] valueForHTTPHeaderField:@"User-agent"];
if(userAgent) {
[req setValue: userAgent forHTTPHeaderField:@"User-agent"];
Expand Down

0 comments on commit 344d5da

Please sign in to comment.