From 777143f5f9dc80f213433634af9fcb9f06924f96 Mon Sep 17 00:00:00 2001 From: Ren Xiao Date: Mon, 8 Jun 2015 11:00:19 +0800 Subject: [PATCH 1/2] Update SVHTTPRequest.h add support for Send parameters as json In POST method --- SVHTTPRequest/SVHTTPRequest.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SVHTTPRequest/SVHTTPRequest.h b/SVHTTPRequest/SVHTTPRequest.h index 8403c52..8f128c9 100644 --- a/SVHTTPRequest/SVHTTPRequest.h +++ b/SVHTTPRequest/SVHTTPRequest.h @@ -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 shutup@2014.8.27#fyjc999@gmail.com ++ (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; @@ -69,4 +72,4 @@ typedef NSUInteger SVHTTPRequestMethod; - (void)signRequestWithUsername:(NSString*)username password:(NSString*)password; -@end \ No newline at end of file +@end From 9347577d939339f5640b39434e700a97a0e2d11a Mon Sep 17 00:00:00 2001 From: Ren Xiao Date: Mon, 8 Jun 2015 11:02:26 +0800 Subject: [PATCH 2/2] Update SVHTTPRequest.m add support for send parameters as json in POST method --- SVHTTPRequest/SVHTTPRequest.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/SVHTTPRequest/SVHTTPRequest.m b/SVHTTPRequest/SVHTTPRequest.m index 044293b..46e7967 100644 --- a/SVHTTPRequest/SVHTTPRequest.m +++ b/SVHTTPRequest/SVHTTPRequest.m @@ -142,6 +142,16 @@ + (SVHTTPRequest*)POST:(NSString *)address parameters:(NSObject *)parameters com return requestObject; } +//added by shutup@2014.8.27#fyjc999@gmail.com ++(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];