开发者

problem by redirected url

开发者 https://www.devze.com 2022-12-22 10:04 出处:网络
opening http://ystatuschecker.com/n/iwall.php?tedad=1 by browser in safari in mac will 开发者_高级运维redirect to http://ystatuschecker.com/n/iwall.php?tedad=5000

opening http://ystatuschecker.com/n/iwall.php?tedad=1 by browser in safari in mac will 开发者_高级运维redirect to http://ystatuschecker.com/n/iwall.php?tedad=5000

i don't know why in my code it's never redirect .

http://yahoo.ir will redirect to http://world.yahoo.com

what's wrong with my URL?

    NSURL *originalUrl=[NSURL URLWithString:@"http://ystatuschecker.com/n/iwall.php?tedad=1"];
NSData *data=nil;  
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:originalUrl cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10];
NSURLResponse *response;
NSError *error;
data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSURL *LastURL=[response URL];
[request release];
[error release];

NSLog(@"%@",LastURL);


I think you should implement the connection:willSendRequest:redirectResponse: delegate method.

From NSURLConnection

Zero or more connection:willSendRequest:redirectResponse: messages will be sent to the delegate before any further messages are sent if it is determined that the download must redirect to a new location. The delegate can allow the redirect, modify the destination or deny the redirect.

Edit

Actually after looking into it the URL you mention doesn't seem to be using a normal http code for a redirect. I'm not sure how they are doing the redirect, but I think that is the issue.


problem solved . i used header("location:htpp://example.com") in php file.

0

精彩评论

暂无评论...
验证码 换一张
取 消