Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Allow user to pass custom cookies

  • Loading branch information...
commit 344d5dac35a4d860ab0057df45db2670aa96e063 1 parent 2bc361d
Matt Kane ascorbic authored

Showing 1 changed file with 10 additions and 4 deletions. Show diff stats Hide diff stats

  1. +10 4 iPhone/FileUploader/FileUploader.m
14 iPhone/FileUploader/FileUploader.m
@@ -102,16 +102,22 @@ - (void) uploadFile:(NSURL*)file toServer:(NSString*)server withParams:(NSMutabl
102 102 if(!fileKey) {
103 103 fileKey = @"file";
104 104 }
105   -
106   - NSString *boundary = @"*****com.beetight.formBoundary";
107   -
108 105 NSURL *url = [NSURL URLWithString:server];
109   -
  106 +
110 107 NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
111 108 [req setHTTPMethod:@"POST"];
112 109
  110 + if([params objectForKey:@"__cookie"]) {
  111 + [req setValue:[params objectForKey:@"__cookie"] forHTTPHeaderField:@"Cookie"];
  112 + [params removeObjectForKey:@"__cookie"];
  113 + [req setHTTPShouldHandleCookies:NO];
  114 + }
  115 +
  116 + NSString *boundary = @"*****com.beetight.formBoundary";
  117 +
113 118 NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
114 119 [req setValue:contentType forHTTPHeaderField:@"Content-type"];
  120 + [req setValue:@"XMLHttpRequest" forHTTPHeaderField:@"X-Requested-With"];
115 121 NSString* userAgent = [[webView request] valueForHTTPHeaderField:@"User-agent"];
116 122 if(userAgent) {
117 123 [req setValue: userAgent forHTTPHeaderField:@"User-agent"];

0 comments on commit 344d5da

Please sign in to comment.
Something went wrong with that request. Please try again.