@@ -849,6 +849,14 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr<
849
849
}
850
850
}
851
851
852
+ ByteBuffer errorBuffer (CURL_ERROR_SIZE);
853
+ if (errorBuffer.GetUnderlyingData () && errorBuffer.GetSize () >= CURL_ERROR_SIZE) {
854
+ errorBuffer[0 ] = ' \0 ' ;
855
+ curl_easy_setopt (connectionHandle, CURLOPT_ERRORBUFFER, errorBuffer.GetUnderlyingData ());
856
+ } else {
857
+ AWS_LOGSTREAM_ERROR (CURL_HTTP_CLIENT_TAG, " Failed to allocate CURLOPT_ERRORBUFFER" );
858
+ }
859
+
852
860
OverrideOptionsOnConnectionHandle (connectionHandle);
853
861
Aws::Utils::DateTime startTransmissionTime = Aws::Utils::DateTime::Now ();
854
862
CURLcode curlResponseCode = curl_easy_perform (connectionHandle);
@@ -858,9 +866,12 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr<
858
866
response->SetClientErrorType (CoreErrors::NETWORK_CONNECTION);
859
867
Aws::StringStream ss;
860
868
ss << " curlCode: " << curlResponseCode << " , " << curl_easy_strerror (curlResponseCode);
869
+ if (errorBuffer.GetUnderlyingData () && errorBuffer.GetSize () >= CURL_ERROR_SIZE) {
870
+ errorBuffer[CURL_ERROR_SIZE-1 ] = ' \0 ' ;
871
+ ss << " ; Details: " << errorBuffer.GetUnderlyingData ();
872
+ }
861
873
response->SetClientErrorMessage (ss.str ());
862
- AWS_LOGSTREAM_ERROR (CURL_HTTP_CLIENT_TAG, " Curl returned error code " << curlResponseCode
863
- << " - " << curl_easy_strerror (curlResponseCode));
874
+ AWS_LOGSTREAM_ERROR (CURL_HTTP_CLIENT_TAG, " Curl returned error: " << response->GetClientErrorMessage ());
864
875
}
865
876
else if (!shouldContinueRequest)
866
877
{
@@ -976,6 +987,8 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr<
976
987
AWS_LOGSTREAM_ERROR (CURL_HTTP_CLIENT_TAG, ss.str ());
977
988
}
978
989
request->AddRequestMetric (GetHttpClientMetricNameByType (HttpClientMetricsType::RequestLatency), (DateTime::Now () - startTransmissionTime).count ());
990
+
991
+ curl_easy_setopt (connectionHandle, CURLOPT_ERRORBUFFER, nullptr );
979
992
}
980
993
981
994
if (headers)
0 commit comments