diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-06-17 19:37:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-17 19:37:46 +0200 |
commit | 3078404e355f900c2afb918307c0deefae5a13c1 (patch) | |
tree | aa998b358e2af520f583b697114b1a945156ad3b /src | |
parent | 2f51cd8dc95231b2e2f5b3bd75ac6d8d2dece361 (diff) | |
parent | 4930cb48a258b0a69a8669602964e3956592ae5c (diff) |
Merge pull request #3712 from obsidiansystems/make-http-successful-states-coherent
Make successful states coherent
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/filetransfer.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc index c954ace7f..531b85af8 100644 --- a/src/libstore/filetransfer.cc +++ b/src/libstore/filetransfer.cc @@ -72,6 +72,7 @@ struct curlFileTransfer : public FileTransfer curl_off_t writtenToSink = 0; + inline static const std::set<long> successfulStatuses {200, 201, 204, 206, 304, 0 /* other protocol */}; /* Get the HTTP status code, or 0 for other protocols. */ long getHTTPStatus() { @@ -98,7 +99,7 @@ struct curlFileTransfer : public FileTransfer /* Only write data to the sink if this is a successful response. */ - if (httpStatus == 0 || httpStatus == 200 || httpStatus == 201 || httpStatus == 206) { + if (successfulStatuses.count(httpStatus)) { writtenToSink += len; this->request.dataCallback((char *) data, len); } @@ -352,8 +353,7 @@ struct curlFileTransfer : public FileTransfer if (writeException) failEx(writeException); - else if (code == CURLE_OK && - (httpStatus == 200 || httpStatus == 201 || httpStatus == 204 || httpStatus == 206 || httpStatus == 304 || httpStatus == 0 /* other protocol */)) + else if (code == CURLE_OK && successfulStatuses.count(httpStatus)) { result.cached = httpStatus == 304; act.progress(result.bodySize, result.bodySize); |