No Description

RNFetchBlobNetwork.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. typedef NS_ENUM(NSUInteger, ResponseFormat) {
  21. UTF8,
  22. BASE64,
  23. AUTO
  24. };
  25. @interface RNFetchBlobNetwork : NSObject <NSURLSessionDelegate, NSURLSessionTaskDelegate, NSURLSessionDataDelegate>
  26. @property (nullable, nonatomic) NSString * taskId;
  27. @property (nonatomic) int expectedBytes;
  28. @property (nonatomic) int receivedBytes;
  29. @property (nonatomic) BOOL isServerPush;
  30. @property (nullable, nonatomic) NSMutableData * respData;
  31. @property (strong, nonatomic) RCTResponseSenderBlock callback;
  32. @property (nullable, nonatomic) RCTBridge * bridge;
  33. @property (nullable, nonatomic) NSDictionary * options;
  34. @property (nullable, nonatomic) RNFetchBlobFS * fileStream;
  35. @property (strong, nonatomic) CompletionHander fileTaskCompletionHandler;
  36. @property (strong, nonatomic) DataTaskCompletionHander dataTaskCompletionHandler;
  37. @property (nullable, nonatomic) NSError * error;
  38. @property (nullable, nonatomic) NSMutableArray * redirects;
  39. @property (nonatomic) BOOL respFile;
  40. @property (nonatomic) BOOL isNewPart;
  41. @property (nonatomic) BOOL isIncrement;
  42. @property (nullable, nonatomic) NSMutableData * partBuffer;
  43. @property (nullable, nonatomic) NSString * destPath;
  44. @property (nullable, nonatomic) NSOutputStream * writeStream;
  45. @property (nonatomic) long bodyLength;
  46. @property (nullable, nonatomic) NSMutableDictionary * respInfo;
  47. @property (nonatomic) NSInteger respStatus;
  48. @property (nonatomic) ResponseFormat responseFormat;
  49. @property ( nonatomic) BOOL followRedirect;
  50. + (NSMutableDictionary * _Nullable ) normalizeHeaders:(NSDictionary * _Nullable)headers;
  51. + (void) cancelRequest:(NSString *)taskId;
  52. + (void) enableProgressReport:(NSString *) taskId;
  53. + (void) enableUploadProgress:(NSString *) taskId;
  54. + (void) emitExpiredTasks;
  55. - (nullable id) init;
  56. - (void) sendRequest;
  57. - (void) sendRequest:(NSDictionary * _Nullable )options contentLength:(long)contentLength bridge:(RCTBridge * _Nullable)bridgeRef taskId:(NSString * _Nullable)taskId withRequest:(NSURLRequest * _Nullable)req callback:(_Nullable RCTResponseSenderBlock) callback;
  58. + (void) removeCookies:(NSString *) domain error:(NSError **)error;
  59. + (void) enableProgressReport:(NSString *) taskId config:(RNFetchBlobProgress *)config;
  60. + (void) enableUploadProgress:(NSString *) taskId config:(RNFetchBlobProgress *)config;
  61. + (NSDictionary *) getCookies:(NSString *) url;
  62. @end
  63. #endif /* RNFetchBlobNetwork_h */