Wednesday, May 1, 2013

NSURLConnection originalRequest example ios


originalRequest

Returns a deep copy of the original connection request.
- (NSURLRequest *)originalRequest
Return Value of [NSURLConnection originalRequest]
Returns a deep copy of the original connection request.
Discussion of [NSURLConnection originalRequest]
As the connection performs the load, this request may change as a result of protocol canonicalization or due to following redirects. The currentRequest method can be used to retrieve this value.
Example of [NSURLConnection originalRequest]
NSString * connectionKey = [[[connection originalRequest] URL] absoluteString];
Example of [NSURLConnection originalRequest]
- (NSURLRequest *)connection: (NSURLConnection *)connection
             willSendRequest: (NSURLRequest *)request
            redirectResponse: (NSURLResponse *)redirectResponse;
{
    if (redirectResponse) {
        NSMutableURLRequest *r = [[originalRequest mutableCopy] autorelease];
        [r setURL: [request URL]];
        return r;
    } else {
        return request;
    }
}