Re: NSURLRequest, forwarding replaces settings in initial request
Re: NSURLRequest, forwarding replaces settings in initial request
- Subject: Re: NSURLRequest, forwarding replaces settings in initial request
- From: John Pannell <email@hidden>
- Date: Thu, 9 Feb 2006 10:30:24 -0700
Hi Alex-
I came across an email on this a few months ago and made note of the
solution (since my app has similar needs). You must reconstruct a
new NSMutableURLRequest in the
connection:willSendRequest:redirectResponse: method of the
NSURLConnection delegate...
-(NSURLRequest *)connection:(NSURLConnection *)connection
willSendRequest:(NSURLRequest *)request redirectResponse:
(NSURLResponse *)redirectResponse
{
NSMutableURLRequest *newRequest = [request mutableCopy];
// returned request has had the UA field stripped, must fix
NSString* userAgentString = @"Mozilla/5.0 (Macintosh; U; PPC Mac
OS X; en-us) AppleWebKit/125.2 (KHTML, like Gecko) Pandora/2.0";
[newRequest setValue:userAgentString forHTTPHeaderField:@"User-
Agent"];
[newRequest setTimeoutInterval:15.0];
[newRequest setCachePolicy:NSURLRequestReloadIgnoringCacheData];
return newRequest;
}
HTH!
John
John Pannell
Positive Spin Media
http://www.positivespinmedia.com
How do I force for the initially set user-agent value to be used
throughout all forwardings?
Thanks for any help.
Alex
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden