Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Commit

Permalink
add a proprietary header to all url requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Reilly authored and Patrick Reilly committed Oct 14, 2011
1 parent a9e489c commit b08725c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Classes/RootViewController.m
Expand Up @@ -32,7 +32,7 @@ - (void)loadStartPage {
NSString *url = [NSString stringWithFormat:@"http://%@.m.wikipedia.org", [appDelegate.settings stringForKey:@"languageKey"]];
NSURL *_url = [NSURL URLWithString:url];
NSMutableURLRequest *URLrequest = [NSMutableURLRequest requestWithURL:_url];
[URLrequest setValue:@"Wikipedia Mobile/2.0" forHTTPHeaderField:@"User_Agent"];
[URLrequest setValue:@"Wikipedia Mobile/2.2.1" forHTTPHeaderField:@"Application_Version"];

[webView loadRequest:URLrequest];
}
Expand Down Expand Up @@ -100,7 +100,7 @@ - (void)loadURL:(NSString *)url {
NSURL *_url = [NSURL URLWithString:url];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:_url];
[request setValue:@"Wikipedia Mobile/2.0" forHTTPHeaderField:@"User_Agent"];
[request setValue:@"Wikipedia Mobile/2.2.1" forHTTPHeaderField:@"Application_Version"];

[webView loadRequest:request];
[request release];
Expand All @@ -113,7 +113,7 @@ - (void)loadWikiEntry:(NSString *)query {
NSURL *_url = [NSURL URLWithString:url];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:_url];
[request setValue:@"Wikipedia Mobile/2.0" forHTTPHeaderField:@"User_Agent"];
[request setValue:@"Wikipedia Mobile/2.2.1" forHTTPHeaderField:@"Application_Version"];

[webView loadRequest:request];
[request release];
Expand Down Expand Up @@ -511,6 +511,16 @@ - (void)hudWasHidden:(MBProgressHUD *)hud {
[hud removeFromSuperview];
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)req navigationType:(UIWebViewNavigationType)navigationType
{
NSMutableURLRequest *request = (NSMutableURLRequest *)req;

if ([request respondsToSelector:@selector(setValue:forHTTPHeaderField:)]) {
[request setValue:@"Wikipedia Mobile/2.2.1" forHTTPHeaderField:@"Application_Version"];
}
return YES;
}

#pragma mark memory/unload

- (void)didReceiveMemoryWarning {
Expand Down

0 comments on commit b08725c

Please sign in to comment.