aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/filetransfer.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-06-26 08:46:46 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-06-26 08:46:46 +0200
commitadf2fbbdc2c94644b0d1023d844c7dc0e485a20f (patch)
tree5999d2c223cb24402995747d79a3de6d6aaebb73 /src/libstore/filetransfer.cc
parent09fc06daab280735dd2ec94276f00a9c5bffd9b2 (diff)
parentb7ccf7ae2af3d7eaf3696358ecbbce5a2bcfe652 (diff)
Merge remote-tracking branch 'origin/master' into flakes
Diffstat (limited to 'src/libstore/filetransfer.cc')
-rw-r--r--src/libstore/filetransfer.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc
index cd15cde62..beb508e67 100644
--- a/src/libstore/filetransfer.cc
+++ b/src/libstore/filetransfer.cc
@@ -73,6 +73,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()
{
@@ -99,7 +100,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);
}
@@ -356,8 +357,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);