2012-03-30 86 views
1

我在我的應用程序內嵌的UIWebView的。我正在做的是,添加一個頭文件(具體來說,授權頭文件),並將其添加到所有請求中。的UIWebView - shouldStartLoadWithRequest - NSMutableURLRequest

當URL從HTML iframe中打開,但這個事件似乎並沒有能夠頭添加到該請求。

可以肯定的,我說在這個事件日誌條目,它確實很好,但如果我使用burpsuite監控HTTP流量,它不添加標題。

有沒有人遇到過這樣的問題永遠不會消失?任何可能的解決方法?

下面是我的代碼,如果它幫助。

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 
{ 
    [(NSMutableURLRequest *)request addBasicAuth:self.accountObj.Username  andPassword:self.accountObj.Password]; 
    NSLog(@"!Request URL :%@",[request URL]); 
    NSLog(@"!Request Header :%@",[request allHTTPHeaderFields]); 
    return YES; 
} 

回答

0

爲什麼不創建一個新的頭,而不是添加一個頭到你的實際請求?

取消那個,並拋出一個新的

+0

我試過下面的代碼,但我做的有點不對。它將該請求分配給主UIWebView,而不是內置iframe。我該如何解決這個問題? – Mihir 2012-03-30 13:16:24

+0

prevUrlString = [NSString stringWithString:[[request URL] absoluteString]]; NSMutableURLRequest *的URLRequest = [[NSMutableURLRequest的alloc] initWithURL:請求URL]]; [urlRequest addBasicAuth:self.accountObj.Username andPassword:self.accountObj.Password]; [webView loadRequest:urlRequest]; – Mihir 2012-03-30 13:16:40