[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.
This commit is contained in:
John Firebaugh
2016-02-04 10:59:36 -08:00
parent 19aa090bdc
commit 4d29c7d5ce
4 changed files with 5 additions and 6 deletions

View File

@@ -38,7 +38,6 @@ public:
NotFound = 2,
Server = 3,
Connection = 4,
Canceled = 5,
Other = 6,
} reason = Reason::Other;

View File

@@ -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>(Error::Reason::Server, messageStr);
break;
case canceledError:
response->error = std::make_unique<Error>(Error::Reason::Canceled, "Request was cancelled");
response.reset();
break;
default:
response->error = std::make_unique<Error>(Error::Reason::Other, messageStr);

View File

@@ -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>(Error::Reason::Canceled, "Request was cancelled");
response.reset();
} else {
if (data) {
response->data =

View File

@@ -24,7 +24,6 @@ inline std::ostream& operator<<(std::ostream& os, Response::Error::Reason r) {
case Response::Error::Reason::NotFound: return os << "Response::Error::Reason::NotFound";
case Response::Error::Reason::Server: return os << "Response::Error::Reason::Server";
case Response::Error::Reason::Connection: return os << "Response::Error::Reason::Connection";
case Response::Error::Reason::Canceled: return os << "Response::Error::Reason::Canceled";
case Response::Error::Reason::Other: return os << "Response::Error::Reason::Other";
default: return os << "<Unknown>";
}