Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLRequest, forwarding replaces settings in initial request



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: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSURLRequest, forwarding replaces settings in initial request (From: alexander reichstadt <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.