mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 14:52:55 +00:00
Downloader: Only write data to the sink on a 200 response
Hopefully fixes #3278.
This commit is contained in:
parent
55cefd41d6
commit
1ab8d6ac18
@ -83,8 +83,15 @@ struct CurlDownloader : public Downloader
|
||||
, callback(std::move(callback))
|
||||
, finalSink([this](const unsigned char * data, size_t len) {
|
||||
if (this->request.dataCallback) {
|
||||
writtenToSink += len;
|
||||
this->request.dataCallback((char *) data, len);
|
||||
long httpStatus = 0;
|
||||
curl_easy_getinfo(req, CURLINFO_RESPONSE_CODE, &httpStatus);
|
||||
|
||||
/* Only write data to the sink if this is a
|
||||
successful response. */
|
||||
if (httpStatus == 0 || httpStatus == 200 || httpStatus == 201 || httpStatus == 206) {
|
||||
writtenToSink += len;
|
||||
this->request.dataCallback((char *) data, len);
|
||||
}
|
||||
} else
|
||||
this->result.data->append((char *) data, len);
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user