猎豆优选

TBSDKConnectionProtocol.h 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //
  2. // TBSDKConnectionProtocol.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. @protocol TBSDKCacheDelegate;
  10. @protocol TBSDKProgressDelegate;
  11. @protocol TBSDKConnectionDelegate;
  12. //和ASI对应轻易不要修改
  13. typedef enum _TBSDKCachePolicy
  14. {
  15. TBSDKUseDefaultCachePolicy = 0,
  16. TBSDKDoNotReadFromCacheCachePolicy = 1,
  17. TBSDKDoNotWriteToCacheCachePolicy = 2,
  18. TBSDKAskServerIfModifiedWhenStaleCachePolicy = 4,
  19. TBSDKAskServerIfModifiedCachePolicy = 8,
  20. TBSDKOnlyLoadIfNotCachedCachePolicy = 16,
  21. TBSDKDontLoadCachePolicy = 32,
  22. TBSDKFallbackToCacheIfLoadFailsCachePolicy = 64
  23. } TBSDKCachePolicy;
  24. typedef enum _TBSDKPostFormat
  25. {
  26. TBSDKMultipartFormDataPostFormat = 0,
  27. TBSDKURLEncodedPostFormat = 1
  28. } TBSDKPostFormat;
  29. @protocol TBSDKConnectionProtocol <NSObject>
  30. @property (unsafe_unretained) id<TBSDKProgressDelegate>uploadProgressDelegate;
  31. @property (nonatomic, strong) NSURL *url;
  32. @property (nonatomic, unsafe_unretained) TBSDKCachePolicy cachePolicy;
  33. @property (unsafe_unretained) id <TBSDKCacheDelegate> downloadCache;
  34. @property (unsafe_unretained, nonatomic) NSTimeInterval timeOutSeconds;
  35. @property (nonatomic, strong) NSDictionary *responseHeaders;
  36. @property (nonatomic, strong) NSMutableDictionary *requestHeaders;
  37. @property (nonatomic, strong) NSError *error;
  38. @property (nonatomic, weak) id<TBSDKConnectionDelegate>delegate;
  39. @property (nonatomic, strong) NSMutableArray *requestCookies;
  40. @property (nonatomic, strong) NSMutableData *responseData;
  41. @property (nonatomic, strong) NSString *responseString;
  42. @property (nonatomic, unsafe_unretained) NSStringEncoding responseEncoding;
  43. @property (assign,readonly) int responseStatusCode;
  44. @property (unsafe_unretained) TBSDKPostFormat postFormat;
  45. @property (nonatomic, strong) NSMutableArray *postData;
  46. + (id)requestWithURL:(NSURL *)newURL;
  47. - (void)setPostValue:(id<NSObject>)value forKey:(NSString *)key;
  48. - (void)addRequestHeader:(NSString *)header value:(NSString *)value;
  49. - (void)startAsynchronous;
  50. - (void)startSynchronous;
  51. - (void)clearDelegatesAndCancel;
  52. - (void)addData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
  53. @end