@@ -849,6 +849,14 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr<
849849 }
850850 }
851851
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+
852860 OverrideOptionsOnConnectionHandle (connectionHandle);
853861 Aws::Utils::DateTime startTransmissionTime = Aws::Utils::DateTime::Now ();
854862 CURLcode curlResponseCode = curl_easy_perform (connectionHandle);
@@ -858,9 +866,12 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr<
858866 response->SetClientErrorType (CoreErrors::NETWORK_CONNECTION);
859867 Aws::StringStream ss;
860868 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+ }
861873 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 ());
864875 }
865876 else if (!shouldContinueRequest)
866877 {
@@ -976,6 +987,8 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr<
976987 AWS_LOGSTREAM_ERROR (CURL_HTTP_CLIENT_TAG, ss.str ());
977988 }
978989 request->AddRequestMetric (GetHttpClientMetricNameByType (HttpClientMetricsType::RequestLatency), (DateTime::Now () - startTransmissionTime).count ());
990+
991+ curl_easy_setopt (connectionHandle, CURLOPT_ERRORBUFFER, nullptr );
979992 }
980993
981994 if (headers)
0 commit comments