QNHttpResponseInfo.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. //
  2. // QNHttpResponseInfo.h
  3. // QiniuSDK
  4. //
  5. // Created by WorkSpace_Sun on 2020/4/19.
  6. // Copyright © 2020 Qiniu. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. @class QNSessionStatistics;
  10. @interface QNHttpResponseInfo : NSObject
  11. /**
  12. * 状态码
  13. */
  14. @property (nonatomic, assign, readonly) int64_t statusCode;
  15. /**
  16. * 服务器域名
  17. */
  18. @property (nonatomic, copy, readonly) NSString *host;
  19. /**
  20. * 错误信息
  21. */
  22. @property (nonatomic, copy, readonly) NSError *error;
  23. /**
  24. * 是否有httpResponse
  25. */
  26. @property (nonatomic, assign, readonly) BOOL hasHttpResponse;
  27. /**
  28. * 七牛服务器生成的请求ID
  29. */
  30. @property (nonatomic, copy, readonly) NSString *reqId;
  31. /**
  32. * 七牛服务器内部跟踪记录
  33. */
  34. @property (nonatomic, copy, readonly) NSString *xlog;
  35. /**
  36. * cdn服务器内部跟踪记录
  37. */
  38. @property (nonatomic, copy, readonly) NSString *xvia;
  39. /**
  40. * 成功的请求
  41. */
  42. @property (nonatomic, assign, readonly, getter=isOK) BOOL ok;
  43. /**
  44. * 是否需要重试
  45. */
  46. @property (nonatomic, assign, readonly) BOOL couldRetry;
  47. /**
  48. * 服务端ip
  49. */
  50. @property (nonatomic, copy, readonly) NSString *remoteIp;
  51. /**
  52. * 服务端端口号
  53. */
  54. @property (nonatomic, assign, readonly) int64_t port;
  55. /**
  56. * 当前时间戳
  57. */
  58. @property (nonatomic, assign, readonly) int64_t timeStamp;
  59. /**
  60. * 从发送请求到收到响应之间的单调时间差,单位为毫秒
  61. */
  62. @property (nonatomic, assign, readonly) int64_t totalElapsedTime;
  63. /**
  64. * 一次请求中 DNS 查询的耗时,单位为毫秒
  65. */
  66. @property (nonatomic, assign, readonly) int64_t dnsElapsedTime;
  67. /**
  68. * ⼀次请求中建立网络连接的耗时,单位为毫秒
  69. */
  70. @property (nonatomic, assign, readonly) int64_t connectElapsedTime;
  71. /**
  72. * ⼀次请求中建立安全⽹络连接的耗时,单位为毫秒
  73. */
  74. @property (nonatomic, assign, readonly) int64_t tlsConnectElapsedTime;
  75. /**
  76. * ⼀次请求中发送请求的耗时,单位为毫秒
  77. */
  78. @property (nonatomic, assign, readonly) int64_t requestElapsedTime;
  79. /**
  80. * ⼀次请求中从发送请求完毕到收到响应前的耗时,单位为毫秒
  81. */
  82. @property (nonatomic, assign, readonly) int64_t waitElapsedTime;
  83. /**
  84. * ⼀次请求中读取响应的耗时,单位为毫秒
  85. */
  86. @property (nonatomic, assign, readonly) int64_t responseElapsedTime;
  87. /**
  88. * 本次成功发送请求的请求体大⼩,单位为字节
  89. */
  90. @property (nonatomic, assign, readonly) int64_t bytesSent;
  91. /**
  92. * 预期发送请求的请求体大小,单位为字节
  93. */
  94. @property (nonatomic, assign, readonly) int64_t bytesTotal;
  95. /**
  96. * 错误类型 用于信息上报
  97. */
  98. @property (nonatomic, copy, readonly) NSString *errorType;
  99. /**
  100. * 错误描述 用于信息上报
  101. */
  102. @property (nonatomic, copy, readonly) NSString *errorDescription;
  103. /**
  104. * 请求是否经过代理服务器
  105. */
  106. @property (nonatomic, assign, readonly, getter=isProxyConnection) BOOL proxyConnection;
  107. /**
  108. * 请求完成时回调的进程id
  109. */
  110. @property (nonatomic, assign, readonly) int64_t pid;
  111. /**
  112. * 请求完成时回调的线程id
  113. */
  114. @property (nonatomic, assign, readonly) int64_t tid;
  115. /**
  116. * 请求结束时的网络类型(需要访问私有属性 statusBar层级结构不稳定 暂不做统计)
  117. */
  118. @property (nonatomic, copy, readonly) NSString *networkType;
  119. /**
  120. * 请求结束时的信号强度(需要访问私有属性 statusBar层级结构不稳定 暂不做统计)
  121. */
  122. @property (nonatomic, assign, readonly) int64_t signalStrength;
  123. /**
  124. * 构造函数
  125. *
  126. * @param host 请求域名
  127. * @param response httpReponse
  128. * @param body httpBody
  129. * @param error 错误信息
  130. * @param sessionStatistics 上传统计数据
  131. *
  132. * @return 实例
  133. */
  134. + (QNHttpResponseInfo *)buildResponseInfoHost:(NSString *)host
  135. response:(NSHTTPURLResponse *)response
  136. body:(NSData *)body
  137. error:(NSError *)error
  138. sessionStatistics:(QNSessionStatistics *)sessionStatistics;
  139. /**
  140. * status == 200 时获取解析后的response body
  141. */
  142. - (NSDictionary *)getResponseBody;
  143. @end