QNCFHttpClient.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // QNHttpClient.h
  3. // AppTest
  4. //
  5. // Created by yangsen on 2020/4/7.
  6. // Copyright © 2020 com.qiniu. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. NS_ASSUME_NONNULL_BEGIN
  10. @protocol QNCFHttpClientDelegate <NSObject>
  11. - (void)redirectedToRequest:(NSURLRequest *)request
  12. redirectResponse:(NSURLResponse *)redirectResponse;
  13. - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
  14. forDomain:(NSString *)domain;
  15. - (void)onError:(NSError *)error;
  16. - (void)didSendBodyData:(int64_t)bytesSent
  17. totalBytesSent:(int64_t)totalBytesSent
  18. totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend;
  19. - (void)onReceiveResponse:(NSURLResponse *)response;
  20. - (void)didLoadData:(NSData *)data;
  21. - (void)didFinish;
  22. @end
  23. @interface QNCFHttpClient : NSObject
  24. @property(nonatomic, strong, readonly)NSMutableURLRequest *request;
  25. @property(nonatomic, weak)id <QNCFHttpClientDelegate> delegate;
  26. + (instancetype)client:(NSURLRequest *)request;
  27. - (void)startLoading;
  28. - (void)stopLoading;
  29. @end
  30. NS_ASSUME_NONNULL_END