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: NSURLConnection nil result (only on 10.4)



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

This email sent to email@hidden

References: 
 >NSURLConnection nil result (only on 10.4) (From: "dexter morgan" <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.