-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDataService.h
47 lines (37 loc) · 1.8 KB
/
DataService.h
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
#import <Foundation/Foundation.h>
#define RESPONSE_OK 200
#define RESPONSE_CLIENT_ERROR 400
#define RESPONSE_SERVER_ERROR 500
@interface DataService : NSObject <NSURLConnectionDelegate>
@property(nonatomic,retain) NSURL *requestURL;
@property(nonatomic) NSInteger statusCode;
@property(nonatomic,readonly,getter = isInProgress) BOOL inProgress;
// Response properties
@property(nonatomic, retain, readonly) NSDictionary *responseHeaders;
@property(nonatomic, readonly) long long expectedContentLength;
@property(nonatomic, retain, readonly) NSString *textEncodingName;
@property(nonatomic, retain, readonly) NSString *MIMEType;
@property(nonatomic, retain, readonly) NSString *suggestedFilename;
+ (DataService*)service;
-(void)requestWithURL:(NSURL*)url
method:(NSString*)method
headers:(NSDictionary*)headers
bodyStream:(NSInputStream*)bodyStream
cachePolicy:(NSURLRequestCachePolicy)cachePolicy
timeoutInterval:(NSTimeInterval)timeoutInterval
receiveHandler:(void (^)(id response, NSNumber *status, NSDictionary *headers))receiveHandler
errorHandler:(void (^)(NSError *error))errorHandler;
-(void)requestWithURL:(NSURL*)url
method:(NSString*)method
headers:(NSDictionary*)headers
bodyStream:(NSInputStream*)bodyStream
receiveHandler:(void (^)(id response, NSNumber *status, NSDictionary *headers))receiveHandler
errorHandler:(void (^)(NSError *error))errorHandler;
-(void)requestWithURL:(NSURL*)url
method:(NSString*)method
headers:(NSDictionary*)headers
body:(NSData*)body
receiveHandler:(void (^)(id response, NSNumber *status, NSDictionary *headers))receiveHandler
errorHandler:(void (^)(NSError *error))errorHandler;
- (void)cancel;
@end