Http/missing change for to lower (#279)
* throw exception on Read from wire Error instead of returning -1 * missing change for tolower
This commit is contained in:
parent
57bdc0f6d6
commit
05c91d6002
@ -69,18 +69,18 @@ CURLcode CurlSession::Perform(Context& context)
|
||||
return result;
|
||||
}
|
||||
|
||||
//curl_easy_setopt(this->m_pCurl, CURLOPT_VERBOSE, 1L);
|
||||
// curl_easy_setopt(this->m_pCurl, CURLOPT_VERBOSE, 1L);
|
||||
// Set timeout to 24h. Libcurl will fail uploading on windows if timeout is:
|
||||
// timeout >= 25 days. Fails as soon as trying to upload any data
|
||||
// 25 days < timeout > 1 days. Fail on huge uploads ( > 1GB)
|
||||
curl_easy_setopt(this->m_pCurl, CURLOPT_TIMEOUT, 60L * 60L * 24L);
|
||||
|
||||
// use expect:100 for PUT requests. Server will decide if it can take our request
|
||||
if (this->m_request.GetMethod() == HttpMethod::Put) {
|
||||
if (this->m_request.GetMethod() == HttpMethod::Put)
|
||||
{
|
||||
this->m_request.AddHeader("expect", "100-continue");
|
||||
}
|
||||
|
||||
|
||||
// establish connection only (won't send or receive anything yet)
|
||||
result = curl_easy_perform(this->m_pCurl);
|
||||
if (result != CURLE_OK)
|
||||
@ -93,16 +93,16 @@ CURLcode CurlSession::Perform(Context& context)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Send request
|
||||
result = HttpRawSend(context);
|
||||
if (result != CURLE_OK)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
ReadStatusLineAndHeadersFromRawResponse();
|
||||
|
||||
|
||||
// Upload body for PUT
|
||||
if (this->m_request.GetMethod() != HttpMethod::Put)
|
||||
{
|
||||
@ -113,12 +113,13 @@ CURLcode CurlSession::Perform(Context& context)
|
||||
// This help to prevent us from start uploading data when Server can't handle it
|
||||
if (this->m_response->GetStatusCode() != HttpStatusCode::Continue)
|
||||
{
|
||||
return result; // Won't upload.
|
||||
return result; // Won't upload.
|
||||
}
|
||||
|
||||
// Start upload
|
||||
result = this->UploadBody(context);
|
||||
if (result != CURLE_OK) {
|
||||
if (result != CURLE_OK)
|
||||
{
|
||||
return result; // will throw trnasport exception before trying to read
|
||||
}
|
||||
ReadStatusLineAndHeadersFromRawResponse();
|
||||
@ -244,7 +245,8 @@ CURLcode CurlSession::SendBuffer(uint8_t const* buffer, size_t bufferSize)
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
CURLcode CurlSession::UploadBody(Context& context) {
|
||||
CURLcode CurlSession::UploadBody(Context& context)
|
||||
{
|
||||
// Send body UploadStreamPageSize at a time (libcurl default)
|
||||
// NOTE: if stream is on top a contiguous memory, we can avoid allocating this copying buffer
|
||||
auto unique_buffer = std::make_unique<uint8_t[]>(UploadStreamPageSize);
|
||||
@ -332,7 +334,7 @@ void CurlSession::ReadStatusLineAndHeadersFromRawResponse()
|
||||
// headers are already loweCase at this point
|
||||
auto headers = this->m_response->GetHeaders();
|
||||
|
||||
auto isContentLengthHeaderInResponse = headers.find("Content-Length");
|
||||
auto isContentLengthHeaderInResponse = headers.find("content-length");
|
||||
if (isContentLengthHeaderInResponse != headers.end())
|
||||
{
|
||||
this->m_contentLength
|
||||
@ -341,7 +343,7 @@ void CurlSession::ReadStatusLineAndHeadersFromRawResponse()
|
||||
}
|
||||
|
||||
this->m_contentLength = -1;
|
||||
auto isTransferEncodingHeaderInResponse = headers.find("Transfer-Encoding");
|
||||
auto isTransferEncodingHeaderInResponse = headers.find("transfer-encoding");
|
||||
if (isTransferEncodingHeaderInResponse != headers.end())
|
||||
{
|
||||
auto headerValue = isTransferEncodingHeaderInResponse->second;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user