QNHttpSingleRequest.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 QNHttpSingleRequest : NSObject
  15. - (instancetype)initWithConfig:(QNConfiguration *)config
  16. uploadOption:(QNUploadOption *)uploadOption
  17. token:(QNUpToken *)token
  18. requestInfo:(QNUploadRequestInfo *)requestInfo
  19. requestState:(QNUploadRequestState *)requestState;
  20. /// 网络请求
  21. /// @param request 请求内容
  22. /// @param server server信息,目前仅用于日志统计
  23. /// @param shouldRetry 判断是否需要重试的block
  24. /// @param progress 上传进度回调
  25. /// @param complete 上传完成回调
  26. - (void)request:(NSURLRequest *)request
  27. server:(id <QNUploadServer>)server
  28. shouldRetry:(BOOL(^)(QNResponseInfo * _Nullable responseInfo, NSDictionary * _Nullable response))shouldRetry
  29. progress:(void(^)(long long totalBytesWritten, long long totalBytesExpectedToWrite))progress
  30. complete:(QNSingleRequestCompleteHandler)complete;
  31. @end
  32. NS_ASSUME_NONNULL_END