QNSessionManager.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #import <Foundation/Foundation.h>
  2. #import "QNConfiguration.h"
  3. #if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000) || (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090)
  4. @class QNHttpResponseInfo;
  5. typedef void (^QNInternalProgressBlock)(long long totalBytesWritten, long long totalBytesExpectedToWrite);
  6. typedef void (^QNCompleteBlock)(QNHttpResponseInfo *httpResponseInfo, NSDictionary *respBody);
  7. typedef BOOL (^QNCancelBlock)(void);
  8. @interface QNSessionStatistics : NSObject
  9. @property (nonatomic, copy) NSString *remoteIp;
  10. @property (nonatomic, assign) int64_t port;
  11. @property (nonatomic, assign) int64_t totalElapsedTime;
  12. @property (nonatomic, assign) int64_t dnsElapsedTime;
  13. @property (nonatomic, assign) int64_t connectElapsedTime;
  14. @property (nonatomic, assign) int64_t tlsConnectElapsedTime;
  15. @property (nonatomic, assign) int64_t requestElapsedTime;
  16. @property (nonatomic, assign) int64_t waitElapsedTime;
  17. @property (nonatomic, assign) int64_t responseElapsedTime;
  18. @property (nonatomic, assign) int64_t bytesSent;
  19. @property (nonatomic, assign) int64_t bytesTotal;
  20. @property (nonatomic, assign, getter=isProxyConnection) BOOL proxyConnection;
  21. @end
  22. @interface QNSessionManager : NSObject
  23. - (instancetype)initWithProxy:(NSDictionary *)proxyDict
  24. timeout:(UInt32)timeout
  25. urlConverter:(QNUrlConvert)converter;
  26. - (void)multipartPost:(NSString *)url
  27. withData:(NSData *)data
  28. withParams:(NSDictionary *)params
  29. withFileName:(NSString *)key
  30. withMimeType:(NSString *)mime
  31. withIdentifier:(NSString *)identifier
  32. withCompleteBlock:(QNCompleteBlock)completeBlock
  33. withProgressBlock:(QNInternalProgressBlock)progressBlock
  34. withCancelBlock:(QNCancelBlock)cancelBlock
  35. withAccess:(NSString *)access;
  36. - (void)post:(NSString *)url
  37. withData:(NSData *)data
  38. withParams:(NSDictionary *)params
  39. withHeaders:(NSDictionary *)headers
  40. withIdentifier:(NSString *)identifier
  41. withCompleteBlock:(QNCompleteBlock)completeBlock
  42. withProgressBlock:(QNInternalProgressBlock)progressBlock
  43. withCancelBlock:(QNCancelBlock)cancelBlock
  44. withAccess:(NSString *)access;
  45. - (void)get:(NSString *)url
  46. withHeaders:(NSDictionary *)headers
  47. withCompleteBlock:(QNCompleteBlock)completeBlock;
  48. - (void)invalidateSessionWithIdentifier:(NSString *)identifier;
  49. @end
  50. #endif