I'm looking for a solution for reading the http status code with a UIWebView. I have found this page on the topic How do I get the last HTTP Status Code from a UIWebView? but i cannot use AsiHttpRequest in my case.
Si I was wondering if somebody have found a solution s开发者_开发知识库ince 2009, and if something similar to NSLog(@"Status code = %@",[webView stringByEvaluatingJavaScriptFromString:@"document.status"]);
could possibly work.
Thanks,
I don't think you can get it from the UIWebView, but I think it would work to have the result of an HTTP request put into an NSString, then parse the status code out of the header part of that string, thing feed that string to a UIWebView.
See the NSURL Class Reference and the URL Loading Programming Guide.
A possible alternative would be to implement an HTTP proxy directly inside your App, then feed a localhost URL to UIWebView. Your proxy would just make an HTTP connection with the web server and sit passively by while UIWebView drives the HTTP protocol. You then snoop on the incoming data before passing it on to UIWebView from your proxy. That would avoid the need to buffer the whole page in an NSString before feeding it to your UIWebView.
精彩评论