Nenhuma descrição

RNFetchBlobNetwork.h 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // RNFetchBlobNetwork.h
  3. // RNFetchBlob
  4. //
  5. // Created by wkh237 on 2016/6/6.
  6. // Copyright © 2016 wkh237. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "RNFetchBlobProgress.h"
  10. #import "RNFetchBlobFS.h"
  11. #if __has_include(<React/RCTAssert.h>)
  12. #import <React/RCTBridgeModule.h>
  13. #else
  14. #import "RCTBridgeModule.h"
  15. #endif
  16. #ifndef RNFetchBlobNetwork_h
  17. #define RNFetchBlobNetwork_h
  18. typedef void(^CompletionHander)(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error);
  19. typedef void(^DataTaskCompletionHander) (NSData * _Nullable resp, NSURLResponse * _Nullable response, NSError * _Nullable error);
  20. @interface RNFetchBlobNetwork : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate>
  21. @property (nullable, nonatomic) NSString * taskId;
  22. @property (nonatomic) int expectedBytes;
  23. @property (nonatomic) int receivedBytes;
  24. @property (nonatomic) BOOL isServerPush;
  25. @property (nullable, nonatomic) NSMutableData * respData;
  26. @property (strong, nonatomic) RCTResponseSenderBlock callback;
  27. @property (nullable, nonatomic) RCTBridge * bridge;
  28. @property (nullable, nonatomic) NSDictionary * options;
  29. @property (nullable, nonatomic) RNFetchBlobFS * fileStream;
  30. @property (strong, nonatomic) CompletionHander fileTaskCompletionHandler;
  31. @property (strong, nonatomic) DataTaskCompletionHander dataTaskCompletionHandler;
  32. @property (nullable, nonatomic) NSError * error;
  33. + (NSMutableDictionary * _Nullable ) normalizeHeaders:(NSDictionary * _Nullable)headers;
  34. + (void) cancelRequest:(NSString *)taskId;
  35. + (void) enableProgressReport:(NSString *) taskId;
  36. + (void) enableUploadProgress:(NSString *) taskId;
  37. + (void) emitExpiredTasks;
  38. - (nullable id) init;
  39. - (void) sendRequest;
  40. - (void) sendRequest:(NSDictionary * _Nullable )options contentLength:(long)contentLength bridge:(RCTBridge * _Nullable)bridgeRef taskId:(NSString * _Nullable)taskId withRequest:(NSURLRequest * _Nullable)req callback:(_Nullable RCTResponseSenderBlock) callback;
  41. + (void) removeCookies:(NSString *) domain error:(NSError **)error;
  42. + (void) enableProgressReport:(NSString *) taskId config:(RNFetchBlobProgress *)config;
  43. + (void) enableUploadProgress:(NSString *) taskId config:(RNFetchBlobProgress *)config;
  44. + (NSDictionary *) getCookies:(NSString *) url;
  45. @end
  46. #endif /* RNFetchBlobNetwork_h */