猎豆优选

MtopExtResponse.h 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //
  2. // MtopExtResponse.h
  3. // mtopext
  4. //
  5. // Created by sihai on 4/11/14.
  6. // Copyright (c) 2014 Taobao. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <MtopSDK/TBSDKRequest.h>
  10. #import <mtopext/Constants.h>
  11. #import <mtopext/MtopError.h>
  12. #import <mtopext/MtopExtRequest.h>
  13. @interface MtopExtResponse : NSObject
  14. @property(assign, nonatomic) int httpResponseCode; // http 响应码
  15. @property(strong, nonatomic) MtopError* error; // 错误信息
  16. @property(strong, nonatomic) NSMutableDictionary* headers; // http响应头
  17. @property(strong, nonatomic) NSData* rawbody; // 原始的http响应body
  18. @property(strong, nonatomic) NSString* body; // 原始的http响应body
  19. @property(strong, nonatomic) NSDictionary* json; // json响应,从http body 解析
  20. @property(assign, nonatomic) BOOL isFromCache; // 响应是否来至cache
  21. @property(assign, nonatomic) BOOL isCacheExpired; // cache是否失效了
  22. @property(strong, nonatomic) MtopExtRequest* request; // 响应对应的API Request
  23. // 为问题排查准备的
  24. @property(strong, nonatomic) NSURL* requestURL; // 底层发出去的URL
  25. @property(strong, nonatomic) NSString* requestMethod; // 底层http 请求方法
  26. @property(strong, nonatomic) NSDictionary* requestHeaders; // 底层发出去的http headers
  27. @property(strong, nonatomic) NSData* requestBody; // 底层发出去的http body
  28. @property(assign, nonatomic) BOOL isLoginCancel;
  29. /*!
  30. * 初始化一个API响应
  31. * @param httpResponseCode http响应码
  32. * @param headers http响应头
  33. * @param rawbody http原始body
  34. * @param isFromCache 是否来自cache
  35. * @param request 对应的request
  36. * @return
  37. * MtopExtResponse
  38. */
  39. - (MtopExtResponse*) initWithHttp: (int) httpResponseCode headers: (NSDictionary*) headers rawbody: (NSData*) rawbody isFromCache: (BOOL) isFromCache request: (MtopExtRequest*) request;
  40. /*!
  41. * 初始化一个API响应
  42. * @param request 底层mtop请求
  43. * @param erequest 对应的request
  44. * @return
  45. * MtopExtResponse
  46. */
  47. - (MtopExtResponse*) initWithRequest: (TBSDKRequest*) request erequest: (MtopExtRequest*) erequest;
  48. /*!
  49. * 初始化一个API响应
  50. * @param error
  51. * @param request 对应的request
  52. * @return
  53. * MtopExtResponse
  54. */
  55. - (MtopExtResponse*) initWithError: (MtopError*) error request: (MtopExtRequest*) request;
  56. /*!
  57. * 使用cache object 初始化一个API响应
  58. * @param co
  59. * @param request 对应的request
  60. * @return
  61. * MtopExtResponse
  62. */
  63. // - (MtopExtResponse*) initWithCacheObject: (TBSDKCacheObject*) co request: (MtopExtRequest*) request;
  64. /*!
  65. * 将另外一个MtopExtResponse的属性复制到本MtopExtResponse
  66. * @param response
  67. * @param request 对应的request
  68. */
  69. - (void) fillWithOther: (MtopExtResponse*) response;
  70. /*!
  71. * 判断响应是否成功
  72. * @return
  73. * YES 成功
  74. * NO 失败
  75. */
  76. - (BOOL) isSucceed;
  77. @end