[core] Add an explicit "not modified" indicator to Response

This commit is contained in:
John Firebaugh
2016-01-13 16:47:36 -08:00
parent 2ee1fe4178
commit 2aafdbc1b8
7 changed files with 43 additions and 40 deletions

View File

@@ -206,17 +206,20 @@ void HTTPAndroidRequest::onResponse(int code, std::string message, std::string e
if (code == 200) {
// Nothing to do; this is what we want
} else if (code == 304) {
response->notModified = true;
if (existingResponse) {
if (existingResponse->error) {
response->error = std::make_unique<Error>(*existingResponse->error);
if (response->expires == Seconds::zero()) {
response->expires = existingResponse->expires;
}
if (response->modified == Seconds::zero()) {
response->modified = existingResponse->modified;
}
if (response->etag.empty()) {
response->etag = existingResponse->etag;
}
response->data = existingResponse->data;
response->modified = existingResponse->modified;
// We're not updating `expired`, it was probably set during the request.
response->etag = existingResponse->etag;
} else {
// This is an unsolicited 304 response and should only happen on malfunctioning
// HTTP servers. It likely doesn't include any data, but we don't have much options.
}
} else if (code == 404) {
response->error = std::make_unique<Error>(Error::Reason::NotFound, "HTTP status code 404");