1

I have to solve the problem that NSURLConnection automatically redirects POST redirects with a 302 response as GET requests (and drops the HTTP body and some headers).

I found and successfully tried the NSURLConnectionDataDelegate solution (e.g. here), implementing:

- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse

and throwing away/fixing the problematic request. This works.

However. As I understand it, this means I have to use the delegate APIs like:

[NSURLConnection connectionWithRequest:request delegate:self];

Is there a way to fix the redirect using the much more comfortable block-based asynchronous API as well?:

+ (void)sendAsynchronousRequest:(NSURLRequest *)request queue:(NSOperationQueue *)queue completionHandler:(void (^)(NSURLResponse*, NSData*, NSError*))handler
Community
  • 1
  • 1
Stefan
  • 1,051
  • 3
  • 11
  • 23

0 Answers0