Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for send parametrs as JSON in POST method #54

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion SVHTTPRequest/SVHTTPRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ typedef NSUInteger SVHTTPRequestMethod;

+ (SVHTTPRequest*)POST:(NSString*)address parameters:(NSObject*)parameters completion:(SVHTTPRequestCompletionHandler)block;
+ (SVHTTPRequest*)POST:(NSString *)address parameters:(NSObject *)parameters progress:(void (^)(float))progressBlock completion:(SVHTTPRequestCompletionHandler)completionBlock;
//added by [email protected]#[email protected]
+ (SVHTTPRequest*)POST:(NSString*)address parameters:(NSObject*)parameters asJson:(BOOL)json completion:(SVHTTPRequestCompletionHandler)block;

+ (SVHTTPRequest*)PUT:(NSString*)address parameters:(NSObject*)parameters completion:(SVHTTPRequestCompletionHandler)block;

+ (SVHTTPRequest*)DELETE:(NSString*)address parameters:(NSDictionary*)parameters completion:(SVHTTPRequestCompletionHandler)block;
Expand Down Expand Up @@ -69,4 +72,4 @@ typedef NSUInteger SVHTTPRequestMethod;

- (void)signRequestWithUsername:(NSString*)username password:(NSString*)password;

@end
@end
10 changes: 10 additions & 0 deletions SVHTTPRequest/SVHTTPRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ + (SVHTTPRequest*)POST:(NSString *)address parameters:(NSObject *)parameters com

return requestObject;
}
//added by [email protected]#[email protected]
+(SVHTTPRequest *)POST:(NSString *)address parameters:(NSObject *)parameters asJson:(BOOL)json completion:(SVHTTPRequestCompletionHandler)block{
SVHTTPRequest *requestObject = [[self alloc] initWithAddress:address method:SVHTTPRequestMethodPOST parameters:parameters saveToPath:nil progress:nil completion:block];

requestObject.sendParametersAsJSON=json;

[requestObject start];

return requestObject;
}

+ (SVHTTPRequest*)POST:(NSString *)address parameters:(NSObject *)parameters progress:(void (^)(float))progressBlock completion:(void (^)(id, NSHTTPURLResponse*, NSError *))completionBlock {
SVHTTPRequest *requestObject = [[self alloc] initWithAddress:address method:SVHTTPRequestMethodPOST parameters:parameters saveToPath:nil progress:progressBlock completion:completionBlock];
Expand Down