// Classes/MainViewController.m:
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
    NSDictionary *headers = [request allHTTPHeaderFields];
    BOOL hasWhateverAddedHeader = NO;
    
    for (NSString *key in [headers allKeys]) {
		if([key isEqualToString:@"X-Access-From-Cordova"]) {
			hasWhateverAddedHeader = YES;
			break;
		}
	}
    
    if (!hasWhateverAddedHeader) {
        NSMutableURLRequest *newRequest = [request mutableCopy];
        [newRequest addValue:@"true" forHTTPHeaderField:@"X-Access-From-Cordova"];
        [theWebView loadRequest:newRequest];
        [newRequest release];
        return NO;
    } else {
        return YES;
    }
}

無理くり。ヘッダはCordovaLibではなくアプリの方いじるだけで行けました。

Comments


Option