Don't use chunked encoding when there is no document
This commit is contained in:
parent
d094db4d89
commit
d037600d0f
3 changed files with 16 additions and 12 deletions
|
@ -8,7 +8,7 @@ static size_t trampoline(char* dest, size_t size, size_t nmemb, void* userp)
|
||||||
return cid->requestWrite(dest, size*nmemb);
|
return cid->requestWrite(dest, size*nmemb);
|
||||||
}
|
}
|
||||||
|
|
||||||
CurlRequester::CurlRequester(QUrl addr, Role role)
|
CurlRequester::CurlRequester(QUrl addr, Role role, Bytestream* singleData)
|
||||||
: _addr(addr), _canWrite(1), _canRead(), _reading(false), _done(false), _dest(nullptr), _size(0), _offset(0), _curl(curl_easy_init())
|
: _addr(addr), _canWrite(1), _canRead(), _reading(false), _done(false), _dest(nullptr), _size(0), _offset(0), _curl(curl_easy_init())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -36,7 +36,15 @@ CurlRequester::CurlRequester(QUrl addr, Role role)
|
||||||
curl_easy_setopt(_curl, CURLOPT_READDATA, this);
|
curl_easy_setopt(_curl, CURLOPT_READDATA, this);
|
||||||
|
|
||||||
_opts = curl_slist_append(_opts, "Expect:");
|
_opts = curl_slist_append(_opts, "Expect:");
|
||||||
|
if(singleData != nullptr)
|
||||||
|
{
|
||||||
|
curl_easy_setopt(_curl, CURLOPT_POSTFIELDSIZE, singleData->size());
|
||||||
|
write((char*)(singleData->raw()), singleData->size());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_opts = curl_slist_append(_opts, "Transfer-Encoding: chunked");
|
_opts = curl_slist_append(_opts, "Transfer-Encoding: chunked");
|
||||||
|
}
|
||||||
_opts = curl_slist_append(_opts, "Content-Type: application/ipp");
|
_opts = curl_slist_append(_opts, "Content-Type: application/ipp");
|
||||||
_opts = curl_slist_append(_opts, "Accept-Encoding: identity");
|
_opts = curl_slist_append(_opts, "Accept-Encoding: identity");
|
||||||
break;
|
break;
|
||||||
|
@ -121,7 +129,7 @@ size_t CurlRequester::requestWrite(char* dest, size_t size)
|
||||||
if(!_reading)
|
if(!_reading)
|
||||||
{
|
{
|
||||||
_canRead.acquire();
|
_canRead.acquire();
|
||||||
if(_done) // Can only have been set by write() - only relevant to check if strating to write
|
if(_done) // Can only have been set by await() - only relevant to check if strating to write
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
HttpGetRequest
|
HttpGetRequest
|
||||||
};
|
};
|
||||||
|
|
||||||
CurlRequester(QUrl addr, Role role = IppRequest);
|
CurlRequester(QUrl addr, Role role = IppRequest, Bytestream* = nullptr);
|
||||||
~CurlRequester();
|
~CurlRequester();
|
||||||
|
|
||||||
CURLcode await(Bytestream* = nullptr);
|
CURLcode await(Bytestream* = nullptr);
|
||||||
|
|
|
@ -38,29 +38,25 @@ void PrinterWorker::getImage(QUrl url)
|
||||||
|
|
||||||
void PrinterWorker::getPrinterAttributes(Bytestream msg)
|
void PrinterWorker::getPrinterAttributes(Bytestream msg)
|
||||||
{
|
{
|
||||||
CurlRequester cr(_printer->httpUrl());
|
CurlRequester cr(_printer->httpUrl(), CurlRequester::IppRequest, &msg);
|
||||||
cr.write((char*)msg.raw(), msg.size());
|
|
||||||
awaitResult(cr, "getPrinterAttributesFinished");
|
awaitResult(cr, "getPrinterAttributesFinished");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrinterWorker::getJobs(Bytestream msg)
|
void PrinterWorker::getJobs(Bytestream msg)
|
||||||
{
|
{
|
||||||
CurlRequester cr(_printer->httpUrl());
|
CurlRequester cr(_printer->httpUrl(), CurlRequester::IppRequest, &msg);
|
||||||
cr.write((char*)msg.raw(), msg.size());
|
|
||||||
awaitResult(cr, "getJobsRequestFinished");
|
awaitResult(cr, "getJobsRequestFinished");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrinterWorker::cancelJob(Bytestream msg)
|
void PrinterWorker::cancelJob(Bytestream msg)
|
||||||
{
|
{
|
||||||
CurlRequester cr(_printer->httpUrl());
|
CurlRequester cr(_printer->httpUrl(), CurlRequester::IppRequest, &msg);
|
||||||
cr.write((char*)msg.raw(), msg.size());
|
|
||||||
awaitResult(cr, "cancelJobFinished");
|
awaitResult(cr, "cancelJobFinished");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrinterWorker::identify(Bytestream msg)
|
void PrinterWorker::identify(Bytestream msg)
|
||||||
{
|
{
|
||||||
CurlRequester cr(_printer->httpUrl());
|
CurlRequester cr(_printer->httpUrl(), CurlRequester::IppRequest, &msg);
|
||||||
cr.write((char*)msg.raw(), msg.size());
|
|
||||||
awaitResult(cr, "identifyFinished");
|
awaitResult(cr, "identifyFinished");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue