forked from TransitApp/SVHTTPRequest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSVHTTPRequest.h
More file actions
72 lines (53 loc) · 2.98 KB
/
Copy pathSVHTTPRequest.h
File metadata and controls
72 lines (53 loc) · 2.98 KB
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
//
// SVHTTPRequest.h
//
// Created by Sam Vermette on 20.09.11.
// Copyright 2011 samvermette.com. All rights reserved.
//
// https://github.com/samvermette/SVHTTPRequest
//
#import <Foundation/Foundation.h>
#import <AvailabilityMacros.h>
#import "SVHTTPClient.h"
enum {
SVHTTPRequestMethodGET = 0,
SVHTTPRequestMethodPOST,
SVHTTPRequestMethodPUT,
SVHTTPRequestMethodDELETE,
SVHTTPRequestMethodHEAD
};
typedef NSUInteger SVHTTPRequestMethod;
@interface SVHTTPRequest : NSOperation
+ (SVHTTPRequest*)GET:(NSString*)address parameters:(NSDictionary*)parameters completion:(SVHTTPRequestCompletionHandler)block;
+ (SVHTTPRequest*)GET:(NSString*)address parameters:(NSDictionary*)parameters saveToPath:(NSString*)savePath progress:(void (^)(float progress))progressBlock completion:(SVHTTPRequestCompletionHandler)completionBlock;
+ (SVHTTPRequest*)POST:(NSString*)address parameters:(NSObject*)parameters completion:(SVHTTPRequestCompletionHandler)block;
+ (SVHTTPRequest*)POST:(NSString *)address parameters:(NSObject *)parameters progress:(void (^)(float))progressBlock completion:(SVHTTPRequestCompletionHandler)completionBlock;
+ (SVHTTPRequest*)PUT:(NSString*)address parameters:(NSObject*)parameters completion:(SVHTTPRequestCompletionHandler)block;
+ (SVHTTPRequest*)DELETE:(NSString*)address parameters:(NSDictionary*)parameters completion:(SVHTTPRequestCompletionHandler)block;
+ (SVHTTPRequest*)HEAD:(NSString*)address parameters:(NSDictionary*)parameters completion:(SVHTTPRequestCompletionHandler)block;
- (SVHTTPRequest*)initWithAddress:(NSString*)urlString
method:(SVHTTPRequestMethod)method
parameters:(NSObject*)parameters
completion:(SVHTTPRequestCompletionHandler)completionBlock;
- (void)preprocessParameters;
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;
+ (void)setDefaultTimeoutInterval:(NSTimeInterval)interval;
+ (void)setDefaultUserAgent:(NSString*)userAgent;
@property (nonatomic, strong) NSString *userAgent;
@property (nonatomic, readwrite) BOOL sendParametersAsJSON;
@property (nonatomic, readwrite) NSURLRequestCachePolicy cachePolicy;
@property (nonatomic, readwrite) NSUInteger timeoutInterval;
@property (nonatomic, strong) NSMutableURLRequest *operationRequest;
@end
// the following methods are only to be accessed from SVHTTPRequest.m and SVHTTPClient.m
@protocol SVHTTPRequestPrivateMethods <NSObject>
@property (nonatomic, strong) NSString *requestPath;
@property (nonatomic, strong) SVHTTPClient *client;
- (SVHTTPRequest*)initWithAddress:(NSString*)urlString
method:(SVHTTPRequestMethod)method
parameters:(NSObject*)parameters
saveToPath:(NSString*)savePath
progress:(void (^)(float))progressBlock
completion:(SVHTTPRequestCompletionHandler)completionBlock;
- (void)signRequestWithUsername:(NSString*)username password:(NSString*)password;
@end