• 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: NSURLConnection nil result (only on 10.4)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection nil result (only on 10.4)


  • Subject: Re: NSURLConnection nil result (only on 10.4)
  • From: "dexter morgan" <email@hidden>
  • Date: Sun, 31 Aug 2008 12:38:19 +0200

I've solved the problem... on 10.4 does not follow redirects so you
need to implement something like this.

-(NSURLRequest *)connection:(NSURLConnection *)connection
willSendRequest:(NSURLRequest *)request
redirectResponse:(NSURLResponse *)redirectResponse {
    NSMutableURLRequest *newRequest = [request mutableCopy];
    // returned request has had the UA field stripped, must fix
    [newRequest setTimeoutInterval:15.0];
    [newRequest setCachePolicy:NSURLRequestReloadIgnoringCacheData];
    return newRequest;
}


On Sun, Aug 31, 2008 at 12:27 PM, dexter morgan <email@hidden> wrote:
> Hello List,
> I'm using NSURLConnection/NSURLRequest in order to download some pages
> from the web.
> My app should be compatible both with 10.4 and 10.5.
> However I've noticed a strange behavior only on 10.4: the method -
> (void)connection:(NSURLConnection *)connection didReceiveData:(NSData
> *)data {
> never called and my _receivedData object still empty.
> The result on - (void)connectionDidFinishLoading:(NSURLConnection
> *)connection  method is a nil content.
>
> The code is:
>
>        _request = [[NSMutableURLRequest alloc] initWithURL: _url];
>        [_request setHTTPMethod: @"POST"];
>        [_request setHTTPShouldHandleCookies: YES];
>
>        // setup user agent (standard mode or custom)
>        [_request setValue: ([_options objectForKey: @"CURLOPT_USERAGENT"] == nil ?
>                                                 STEALTH_USERAGENT :
>                                                 [_options objectForKey: @"CURLOPT_USERAGENT"])
>                forHTTPHeaderField:@"User-Agent"];
>
>        // init session data container
>        [_receivedData release];
>        _receivedData= [[NSMutableData alloc] init];
>
>        // create a new connection
>        [_connection release];
>        _connection = [[[NSURLConnection alloc] initWithRequest: _request
> delegate: self] retain];
>
> All works fine on 10.5.
> I've also noticed that this error happends only for certain address.
> For example this works fine:
> http://www.tim.it/consumer/homepage.do
>
> while these not:
> https://www.190.it/190/trilogy/jsp/login.do
> http://www.tele2internet.it/clogin.phtml
>
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSURLConnection nil result (only on 10.4) (From: "dexter morgan" <email@hidden>)

  • Prev by Date: NSURLConnection nil result (only on 10.4)
  • Next by Date: activateIgnoringOtherApps
  • Previous by thread: NSURLConnection nil result (only on 10.4)
  • Next by thread: activateIgnoringOtherApps
  • Index(es):
    • Date
    • Thread