Przeglądaj źródła

Replaced #1345 - Added urlCredential property to SDWebImageDownloader

Bogdan Poplauschi 10 lat temu
rodzic
commit
dcb7985

+ 5 - 0
SDWebImage/SDWebImageDownloader.h

@@ -109,6 +109,11 @@ typedef NSDictionary *(^SDWebImageDownloaderHeadersFilterBlock)(NSURL *url, NSDi
  */
 + (SDWebImageDownloader *)sharedDownloader;
 
+/**
+ *  Set the default URL credential to be set for request operations.
+ */
+@property (strong, nonatomic) NSURLCredential *urlCredential;
+
 /**
  * Set username
  */

+ 3 - 1
SDWebImage/SDWebImageDownloader.m

@@ -172,7 +172,9 @@ static NSString *const kCompletedCallbackKey = @"completed";
                                                         }];
         operation.shouldDecompressImages = wself.shouldDecompressImages;
         
-        if (wself.username && wself.password) {
+        if (wself.urlCredential) {
+            operation.credential = wself.urlCredential;
+        } else if (wself.username && wself.password) {
             operation.credential = [NSURLCredential credentialWithUser:wself.username password:wself.password persistence:NSURLCredentialPersistenceForSession];
         }