Sfoglia il codice sorgente

http downloader: use our own user-agent

Felix Paul Kühne 11 anni fa
parent
commit
49d45e2997
1 ha cambiato i file con 2 aggiunte e 0 eliminazioni
  1. 2 0
      Sources/VLCHTTPFileDownloader.m

+ 2 - 0
Sources/VLCHTTPFileDownloader.m

@@ -44,6 +44,7 @@
         [fileManager createDirectoryAtPath:basePath withIntermediateDirectories:YES attributes:nil error:nil];
     _expectedDownloadSize = _receivedDataSize = 0;
     NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
+    [theRequest addValue:[NSString stringWithFormat:@"Mozilla/5.0 (%@; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/%@ Mobile/11A465 Safari/9537.53 VLC for iOS/%@", UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? @"iPad" : @"iPhone", [[UIDevice currentDevice] systemVersion], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] forHTTPHeaderField:@"User-Agent"];
     _urlConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
     if (!_urlConnection) {
         APLog(@"failed to establish connection");
@@ -66,6 +67,7 @@
         [fileManager createDirectoryAtPath:basePath withIntermediateDirectories:YES attributes:nil error:nil];
     _expectedDownloadSize = _receivedDataSize = 0;
     NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
+    [theRequest addValue:[NSString stringWithFormat:@"Mozilla/5.0 (%@; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/%@ Mobile/11A465 Safari/9537.53 VLC for iOS/%@", UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? @"iPad" : @"iPhone", [[UIDevice currentDevice] systemVersion], [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] forHTTPHeaderField:@"User-Agent"];
     _urlConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
     if (!_urlConnection) {
         APLog(@"failed to establish connection");