From 4d29c7d5cec6d6261431ea705ceab500768c3e3a Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 4 Feb 2016 10:59:36 -0800 Subject: [core] Remove Response::Error::Reason::Canceled There is no such thing as a cancelled response, only cancelled requests. A request that is cancelled does not have its callback called with a Response. --- platform/android/src/http_request_android.cpp | 3 ++- platform/darwin/http_request_nsurl.mm | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'platform') diff --git a/platform/android/src/http_request_android.cpp b/platform/android/src/http_request_android.cpp index 9db7416906..390334627a 100644 --- a/platform/android/src/http_request_android.cpp +++ b/platform/android/src/http_request_android.cpp @@ -172,6 +172,7 @@ void HTTPAndroidRequest::cancel() { void HTTPAndroidRequest::finish() { if (!cancelled) { + assert(response); notify(*response); } @@ -234,7 +235,7 @@ void HTTPAndroidRequest::onFailure(JNIEnv* env, int type, jstring message) { response->error = std::make_unique(Error::Reason::Server, messageStr); break; case canceledError: - response->error = std::make_unique(Error::Reason::Canceled, "Request was cancelled"); + response.reset(); break; default: response->error = std::make_unique(Error::Reason::Other, messageStr); diff --git a/platform/darwin/http_request_nsurl.mm b/platform/darwin/http_request_nsurl.mm index 0166564727..fa705638b4 100644 --- a/platform/darwin/http_request_nsurl.mm +++ b/platform/darwin/http_request_nsurl.mm @@ -133,7 +133,7 @@ void HTTPNSURLRequest::handleResponse() { } if (!cancelled) { - // Actually return the response. + assert(response); notify(*response); } @@ -158,8 +158,8 @@ void HTTPNSURLRequest::handleResult(NSData *data, NSURLResponse *res, NSError *e if (error) { if ([error code] == NSURLErrorCancelled) { - response->error = - std::make_unique(Error::Reason::Canceled, "Request was cancelled"); + response.reset(); + } else { if (data) { response->data = -- cgit v1.2.1