Don't use chunked encoding when there is no document
This commit is contained in:
parent
56395707fa
commit
46e101f016
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);
|
||||
}
|
||||
|
||||
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())
|
||||
{
|
||||
|
||||
|
@ -36,7 +36,15 @@ CurlRequester::CurlRequester(QUrl addr, Role role)
|
|||
curl_easy_setopt(_curl, CURLOPT_READDATA, this);
|
||||
|
||||
_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, "Content-Type: application/ipp");
|
||||
_opts = curl_slist_append(_opts, "Accept-Encoding: identity");
|
||||
break;
|
||||
|
@ -121,7 +129,7 @@ size_t CurlRequester::requestWrite(char* dest, size_t size)
|
|||
if(!_reading)
|
||||
{
|
||||
_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;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
HttpGetRequest
|
||||
};
|
||||
|
||||
CurlRequester(QUrl addr, Role role = IppRequest);
|
||||
CurlRequester(QUrl addr, Role role = IppRequest, Bytestream* = nullptr);
|
||||
~CurlRequester();
|
||||
|
||||
CURLcode await(Bytestream* = nullptr);
|
||||
|
|
|
@ -38,29 +38,25 @@ void PrinterWorker::getImage(QUrl url)
|
|||
|
||||
void PrinterWorker::getPrinterAttributes(Bytestream msg)
|
||||
{
|
||||
CurlRequester cr(_printer->httpUrl());
|
||||
cr.write((char*)msg.raw(), msg.size());
|
||||
CurlRequester cr(_printer->httpUrl(), CurlRequester::IppRequest, &msg);
|
||||
awaitResult(cr, "getPrinterAttributesFinished");
|
||||
}
|
||||
|
||||
void PrinterWorker::getJobs(Bytestream msg)
|
||||
{
|
||||
CurlRequester cr(_printer->httpUrl());
|
||||
cr.write((char*)msg.raw(), msg.size());
|
||||
CurlRequester cr(_printer->httpUrl(), CurlRequester::IppRequest, &msg);
|
||||
awaitResult(cr, "getJobsRequestFinished");
|
||||
}
|
||||
|
||||
void PrinterWorker::cancelJob(Bytestream msg)
|
||||
{
|
||||
CurlRequester cr(_printer->httpUrl());
|
||||
cr.write((char*)msg.raw(), msg.size());
|
||||
CurlRequester cr(_printer->httpUrl(), CurlRequester::IppRequest, &msg);
|
||||
awaitResult(cr, "cancelJobFinished");
|
||||
}
|
||||
|
||||
void PrinterWorker::identify(Bytestream msg)
|
||||
{
|
||||
CurlRequester cr(_printer->httpUrl());
|
||||
cr.write((char*)msg.raw(), msg.size());
|
||||
CurlRequester cr(_printer->httpUrl(), CurlRequester::IppRequest, &msg);
|
||||
awaitResult(cr, "identifyFinished");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue