mirror of
https://github.com/NixOS/nix
synced 2025-06-24 22:11:15 +02:00
Merge pull request #13121 from tomberek/tomberek.redirect_http
fix: allow redirected HTTP uploads
This commit is contained in:
commit
469a6371ec
1 changed files with 19 additions and 0 deletions
|
@ -312,6 +312,23 @@ struct curlFileTransfer : public FileTransfer
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
size_t seekCallback(curl_off_t offset, int origin)
|
||||||
|
{
|
||||||
|
if (origin == SEEK_SET) {
|
||||||
|
readOffset = offset;
|
||||||
|
} else if (origin == SEEK_CUR) {
|
||||||
|
readOffset += offset;
|
||||||
|
} else if (origin == SEEK_END) {
|
||||||
|
readOffset = request.data->length() + offset;
|
||||||
|
}
|
||||||
|
return CURL_SEEKFUNC_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t seekCallbackWrapper(void *clientp, curl_off_t offset, int origin)
|
||||||
|
{
|
||||||
|
return ((TransferItem *) clientp)->seekCallback(offset, origin);
|
||||||
|
}
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
if (!req) req = curl_easy_init();
|
if (!req) req = curl_easy_init();
|
||||||
|
@ -364,6 +381,8 @@ struct curlFileTransfer : public FileTransfer
|
||||||
curl_easy_setopt(req, CURLOPT_READFUNCTION, readCallbackWrapper);
|
curl_easy_setopt(req, CURLOPT_READFUNCTION, readCallbackWrapper);
|
||||||
curl_easy_setopt(req, CURLOPT_READDATA, this);
|
curl_easy_setopt(req, CURLOPT_READDATA, this);
|
||||||
curl_easy_setopt(req, CURLOPT_INFILESIZE_LARGE, (curl_off_t) request.data->length());
|
curl_easy_setopt(req, CURLOPT_INFILESIZE_LARGE, (curl_off_t) request.data->length());
|
||||||
|
curl_easy_setopt(req, CURLOPT_SEEKFUNCTION, seekCallbackWrapper);
|
||||||
|
curl_easy_setopt(req, CURLOPT_SEEKDATA, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.verifyTLS) {
|
if (request.verifyTLS) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue