Skip to content
Open
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
25 changes: 2 additions & 23 deletions SVHTTPRequest/SVHTTPRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -554,30 +554,9 @@ - (void)callCompletionBlockWithResponse:(id)response error:(NSError *)error {
if(self.operationRunLoop)
CFRunLoopStop(self.operationRunLoop);

dispatch_async(dispatch_get_main_queue(), ^{
NSError *serverError = error;

if(!serverError) {
if(self.operationURLResponse.statusCode == 500) {
serverError = [NSError errorWithDomain:NSURLErrorDomain
code:NSURLErrorBadServerResponse
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
@"Bad Server Response.", NSLocalizedDescriptionKey,
self.operationRequest.URL, NSURLErrorFailingURLErrorKey,
self.operationRequest.URL.absoluteString, NSURLErrorFailingURLStringErrorKey, nil]];
}
else if(self.operationURLResponse.statusCode > 299) {
serverError = [NSError errorWithDomain:NSURLErrorDomain
code:self.operationURLResponse.statusCode
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:
self.operationRequest.URL, NSURLErrorFailingURLErrorKey,
self.operationRequest.URL.absoluteString, NSURLErrorFailingURLStringErrorKey, nil]];

}
}

dispatch_async(dispatch_get_main_queue(), ^{
if(self.operationCompletionBlock && !self.isCancelled)
self.operationCompletionBlock(response, self.operationURLResponse, serverError);
self.operationCompletionBlock(response, self.operationURLResponse, error);

[self finish];
});
Expand Down