changeset 5095:b52fe770aec0

more logs in HttpClient
author Alain Mazy <am@osimis.io>
date Wed, 12 Oct 2022 09:22:08 +0200
parents cc1a8b3ff319
children 1faae6dc282f
files OrthancFramework/Sources/HttpClient.cpp
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/HttpClient.cpp	Fri Sep 30 15:17:21 2022 +0200
+++ b/OrthancFramework/Sources/HttpClient.cpp	Wed Oct 12 09:22:08 2022 +0200
@@ -46,7 +46,7 @@
 
 extern "C"
 {
-  static CURLcode GetHttpStatus(CURLcode code, CURL* curl, long* status)
+  static CURLcode GetHttpStatus(CURLcode code, CURL* curl, long* status, const std::string& url)
   {
     if (code == CURLE_OK)
     {
@@ -56,7 +56,8 @@
     else
     {
       LOG(ERROR) << "Error code " << static_cast<int>(code)
-                 << " in libcurl: " << curl_easy_strerror(code);
+                 << " in libcurl: " << curl_easy_strerror(code)
+                 << " while accessing url: " << url;
       *status = 0;
       return code;
     }
@@ -68,10 +69,10 @@
 #if defined(__GNUC__) || defined(__clang__)
 __attribute__((noinline)) 
 #endif
-static CURLcode OrthancHttpClientPerformSSL(CURL* curl, long* status)
+static CURLcode OrthancHttpClientPerformSSL(CURL* curl, long* status, const std::string& url)
 {
 #if ORTHANC_ENABLE_SSL == 1
-  return GetHttpStatus(curl_easy_perform(curl), curl, status);
+  return GetHttpStatus(curl_easy_perform(curl), curl, status, url);
 #else
   throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
                                   "Orthanc was compiled without SSL support, "
@@ -1045,11 +1046,11 @@
     
     if (boost::starts_with(url_, "https://"))
     {
-      code = OrthancHttpClientPerformSSL(pimpl_->curl_, &status);
+      code = OrthancHttpClientPerformSSL(pimpl_->curl_, &status, url_);
     }
     else
     {
-      code = GetHttpStatus(curl_easy_perform(pimpl_->curl_), pimpl_->curl_, &status);
+      code = GetHttpStatus(curl_easy_perform(pimpl_->curl_), pimpl_->curl_, &status, url_);
     }
 
     const boost::posix_time::ptime end = boost::posix_time::microsec_clock::universal_time();