Ei kuvausta

TBSDKConnection.h 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // TBSDKConnection.h
  3. // TBSDK
  4. //
  5. // Created by 亿刀/禚来强 on 14-3-6.
  6. // Copyright (c) 2014年 Taobao.com. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "TBSDKConnectionProtocol.h"
  10. @protocol TBSDKProgressDelegate;
  11. @protocol TBSDKConnectionDelegate;
  12. //和ASI对应轻易不要修改
  13. typedef enum _TBSDKNetworkErrorType {
  14. TBSDKConnectionFailureErrorType = 1,
  15. TBSDKRequestTimedOutErrorType = 2,
  16. TBSDKAuthenticationErrorType = 3,
  17. TBSDKRequestCancelledErrorType = 4,
  18. TBSDKUnableToCreateRequestErrorType = 5,
  19. TBSDKInternalErrorWhileBuildingRequestType = 6,
  20. TBSDKInternalErrorWhileApplyingCredentialsType = 7,
  21. TBSDKFileManagementError = 8,
  22. TBSDKTooMuchRedirectionErrorType = 9,
  23. TBSDKUnhandledExceptionError = 10,
  24. TBSDKCompressionError = 11,
  25. TBSDKACCSError = 12,
  26. } TBSDKNetworkErrorType;
  27. @interface TBSDKConnection : NSObject
  28. @property (weak) id<TBSDKProgressDelegate>uploadProgressDelegate;
  29. @property (nonatomic, strong) NSURL *url;
  30. @property (nonatomic, unsafe_unretained) TBSDKCachePolicy cachePolicy;
  31. @property (unsafe_unretained) id <TBSDKCacheDelegate> downloadCache;
  32. @property (weak) id <TBSDKProgressDelegate> downloadProgressDelegate;
  33. @property (unsafe_unretained, nonatomic) NSTimeInterval timeOutSeconds;
  34. @property (nonatomic, strong) NSDictionary *responseHeaders;
  35. @property (nonatomic, strong) NSMutableDictionary *requestHeaders;
  36. @property (nonatomic, strong) NSError *error;
  37. @property (nonatomic, weak) id<TBSDKConnectionDelegate>delegate;
  38. @property (nonatomic, strong) NSMutableArray *requestCookies;
  39. @property (nonatomic, strong) NSData *responseData;
  40. @property (nonatomic, strong) NSString *responseString;
  41. @property (nonatomic, unsafe_unretained) NSStringEncoding responseEncoding;
  42. @property (assign,nonatomic) int responseStatusCode;
  43. @property (unsafe_unretained) TBSDKPostFormat postFormat;
  44. @property (strong) NSMutableArray *fileData;
  45. @property (strong) NSHTTPURLResponse *response;
  46. @property (strong) NSMutableData *postBody;
  47. @property (atomic) BOOL isFinished;
  48. // 打点判断是否是http
  49. @property (nonatomic, unsafe_unretained) BOOL isHttp;
  50. @property (nonatomic, strong) NSMutableArray *postData;
  51. @property (nonatomic, unsafe_unretained) int postGzipSize;
  52. // ut dataset dictionary
  53. @property (nonatomic, strong) NSDictionary *utDict;
  54. @property (nonatomic) CFAbsoluteTime networkEndTime;
  55. + (id)requestWithURL:(NSURL *)newURL;
  56. + (void) cancelAll;
  57. - (id)initWithURL:(NSURL *)newURL;
  58. - (void)setPostValue:(id<NSObject>)value forKey:(NSString *)key;
  59. - (void)addRequestHeader:(NSString *)header value:(NSString *)value;
  60. - (void)startAsynchronous;
  61. - (void)startSynchronous;
  62. - (void)clearDelegatesAndCancel;
  63. - (void)addData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
  64. @end