TransitApp/SVHTTPRequest

Logical issue when sending parameters as JSON

svilon opened this issue · 1 comments

There is a logical issue when creating request with sendParametersAsJSON=YES;

In SVHTTPClient.m:

  • (SVHTTPRequest_)queueRequest:(NSString_)path
    method:(SVHTTPRequestMethod)method
    parameters:(NSDictionary_)parameters
    saveToPath:(NSString_)savePath
    progress:(void (^)(float))progressBlock
    completion:(SVHTTPRequestCompletionHandler)completionBlock {

{...}
SVHTTPRequest *requestOperation = [(id)[SVHTTPRequest alloc] initWithAddress:completeURLString
method:method
parameters:mergedParameters
saveToPath:savePath
sendAsJSON:self.sendParametersAsJSON
progress:progressBlock
completion:completionBlock];
return [self queueRequest:requestOperation];
}

  • (SVHTTPRequest_)queueRequest:(SVHTTPRequest_)requestOperation {
    requestOperation.sendParametersAsJSON = self.sendParametersAsJSON;
    {...}
    return requestOperation;
    }

requestOperation.sendParametersAsJSON will be set to YES after initialization, but in SVHTTPRequest.m addParametersToRequest: method is called inside of init method and at that time sendParametersAsJSON is always NO. As a result, I'm unable to send parameters as JSON :)

mkll commented

Faced the same situation