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

HTTP Status code should be handled manually by developer #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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