[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

@@ -529,18 +529,20 @@ void HTTPCURLRequest::handleResult(CURLcode code) {
if (responseCode == 200) {
// Nothing to do; this is what we want.
} else if (responseCode == 304) {
response->notModified = true;
if (existingResponse) {
// We're going to copy over the existing response's data.
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 (responseCode == 404) {
response->error =