QNHttpSingleRequest.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // QNHttpRequest+SingleRequestRetry.h
  3. // QiniuSDK
  4. //
  5. // Created by yangsen on 2020/4/29.
  6. // Copyright © 2020 Qiniu. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "QNUploadRequestInfo.h"
  10. #import "QNIUploadServer.h"
  11. NS_ASSUME_NONNULL_BEGIN
  12. @class QNUploadRequestState, QNResponseInfo, QNConfiguration, QNUploadOption, QNUpToken, QNUploadSingleRequestMetrics;
  13. typedef void(^QNSingleRequestCompleteHandler)(QNResponseInfo * _Nullable responseInfo, NSArray <QNUploadSingleRequestMetrics *> * _Nullable metrics, NSDictionary * _Nullable response);
  14. @interface QNUploadRequestState : NSObject
  15. @property(atomic, assign)BOOL isUserCancel;
  16. @end
  17. @interface QNHttpSingleRequest : NSObject
  18. - (instancetype)initWithConfig:(QNConfiguration *)config
  19. uploadOption:(QNUploadOption *)uploadOption
  20. token:(QNUpToken *)token
  21. requestInfo:(QNUploadRequestInfo *)requestInfo
  22. requestState:(QNUploadRequestState *)requestState;
  23. /// 网络请求
  24. /// @param request 请求内容
  25. /// @param server server信息,目前仅用于日志统计
  26. /// @param toSkipDns 请求是否需要跳过Dns 当请求的中配置了IP即可跳过 反之不跳过
  27. /// @param shouldRetry 判断是否需要重试的block
  28. /// @param progress 上传进度回调
  29. /// @param complete 上传完成回调
  30. - (void)request:(NSURLRequest *)request
  31. server:(id <QNUploadServer>)server
  32. toSkipDns:(BOOL)toSkipDns
  33. shouldRetry:(BOOL(^)(QNResponseInfo * _Nullable responseInfo, NSDictionary * _Nullable response))shouldRetry
  34. progress:(void(^)(long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
  35. complete:(QNSingleRequestCompleteHandler)complete;
  36. @end
  37. NS_ASSUME_NONNULL_END