i'm accessing an API over HTTP and use ASIHTTPRequest. To access the API I have to send additional headers, which i add with the following:
[request addRequestHeader:@"Access-Key" value:@"1234"];
These headers have to be sent with every request. When I get redirected these headers get lost so i'd like to set them again. Is there any possibility to set them again, before the redirect request is beeing performed?
When I implement the - (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL Method, the request gets cancelled after this delegate function is called. Is it a bug? I'm using the version v1.8.1-8 2011-06-05.
Thanks for your help!
I could solve the Problem. IMO the naming of the method is a bit confusing. When you implement - (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL
the Method is called, but after the request isn't redirected as I asumed. You have to redirect the request by yourself:
- (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL {
// modify request here, e.g. set request headers again...
[request redirectToURL:newURL];
}
Thanks for reading my question, hope this helps anyone else.