iPhoneQ
iPhoneQ

Reputation: 105

Loading web view taking more time with ASIHTTPRequest in ios

In my browser based application, I need to set a proxy for each url and doing this with the help of ASIHTTPRequest.

The problem I am facing is that the web view is taking double the time to load the page, probably because I am loading the page twice in my code.

First I check the status with ASIHTTPRequest to determine if the page is allowed to load by ASIHTTPRequest and if so, then I load that url on web-view. This is where I think the problem is as I think I am loading the url two times which is consuming time.

Can you make a suggestion on other ways to load page once, but in a way that supports checking for authenticated page with usage of proxy settings, or provide me with a link to guide relevant to this question?

NSString *response = [NSString stringWithContentsOfFile:
    [theRequest downloadDestinationPath] encoding:[theRequest responseEncoding] error:nil];
    int statusCode = [requestH responseStatusCode];
    if (statusCode == 200) {
        [webV loadRequest:[NSURLRequest  requestWithURL:[requestH url]]];
    }
    else {
        [webV loadHTMLString:response baseURL:[theRequest url]];
    }

Upvotes: 4

Views: 440

Answers (1)

alinoz
alinoz

Reputation: 2822

Implement the delegate methods of NSURLConnection (apple docu) and in the connectionDidFinishLoading save the content of the url to a local file and then in load this local file with loadHTMLString.

Upvotes: 1

Related Questions