I am working on an iOS app which interacts with a remote WS. As the URL of the WS might change from time to time, the app should send all the requests to a fixed and stable URL which takes care of redirecting them to the actual URL of the WS.
Here is my code:
- (NSURLRequest *)connection: (NSURLConnection *)connection
willSendRequest: (NSURLRequest *)request
redirectResponse: (NSURLResponse *)redirectResponse {
if (redirectResponse) {
NSMutableURLRequest *r = [lastRequest mutableCopy];
[r setURL: [request URL]];
return r;
} else {
return request;
}
}
where lastRequest is a copy of the original request that has been sent.
Here is my problem: I don't know why but the new request, that is r, is sent with an empty body (no parameters). Looks like all the parameters of the original request are lost, even if I use an exact copy of the original request.
What do you guys think? How could I fix this problem?
Thanks!