GIDHTTPFetcher.m 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. #import "GoogleSignIn/Sources/GIDHTTPFetcher/Implementations/GIDHTTPFetcher.h"
  2. @import GTMAppAuth;
  3. #import <GTMSessionFetcher/GTMSessionFetcher.h>
  4. NS_ASSUME_NONNULL_BEGIN
  5. // Maximum retry interval in seconds for the fetcher.
  6. static const NSTimeInterval kFetcherMaxRetryInterval = 15.0;
  7. @implementation GIDHTTPFetcher
  8. - (void)fetchURLRequest:(NSURLRequest *)urlRequest
  9. #pragma clang diagnostic ignored "-Wdeprecated-declarations"
  10. withFetcherService:(id<GTMSessionFetcherServiceProtocol>)fetcherService
  11. #pragma clang diagnostic pop
  12. withComment:(NSString *)comment
  13. completion:(void (^)(NSData *_Nullable, NSError *_Nullable))completion {
  14. GTMSessionFetcher *fetcher;
  15. if (fetcherService) {
  16. fetcher = [fetcherService fetcherWithRequest:urlRequest];
  17. } else {
  18. fetcher = [GTMSessionFetcher fetcherWithRequest:urlRequest];
  19. }
  20. fetcher.retryEnabled = YES;
  21. fetcher.maxRetryInterval = kFetcherMaxRetryInterval;
  22. fetcher.comment = comment;
  23. [fetcher beginFetchWithCompletionHandler:completion];
  24. }
  25. @end
  26. NS_ASSUME_NONNULL_END