• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSURLRequest, forwarding replaces settings in initial request
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >NSURLRequest, forwarding replaces settings in initial request (From: alexander reichstadt <email@hidden>)

  • Prev by Date: NSURLRequest, forwarding replaces settings in initial request
  • Next by Date: Re: NSURLRequest, forwarding replaces settings in initial request
  • Previous by thread: NSURLRequest, forwarding replaces settings in initial request
  • Next by thread: Re: NSURLRequest, forwarding replaces settings in initial request
  • Index(es):
    • Date
    • Thread