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