[PATCH] Don’t use http_client_config when not needed
authorVáclav Slavík <vaclav@slavik.io>
Sat, 29 Oct 2016 16:08:35 +0000 (18:08 +0200)
committerGianfranco Costamagna <locutusofborg@debian.org>
Fri, 6 Jan 2017 07:32:48 +0000 (07:32 +0000)
Don’t pass default http_client_config to http_client if not needed, i.e.
elsewhere than Windows.

This fixes a crash in C++REST SDK reported by Debian. Cause is unknown,
but related to http_client_config and when that is not used on Linux
anyway, why make things harder for everybody.

Gbp-Pq: Name e5d68f3851341c59c712763e69839042e630555a.patch

src/http_client_casablanca.cpp

index 056fc0a53332c81dc48e43b9693d29a1feeaf2e3..a4d66e7e642a005c1498d5f1ed4c742662746f29 100644 (file)
@@ -169,7 +169,14 @@ class http_client::impl
 {
 public:
     impl(http_client& owner, const std::string& url_prefix, int flags)
-        : m_owner(owner), m_native(sanitize_url(url_prefix, flags), get_client_config())
+        : m_owner(owner),
+          m_native
+          (
+              sanitize_url(url_prefix, flags)
+            #ifdef _WIN32
+              , get_client_config()
+            #endif
+          )
     {
         #define make_wide_str(x) make_wide_str_(x)
         #define make_wide_str_(x) L ## x
@@ -361,11 +368,12 @@ private:
         return to_string_t(url);
     }
 
+#ifdef _WIN32
     // prepare WinHttp configuration
     static http::client::http_client_config get_client_config()
     {
         http::client::http_client_config c;
-    #ifdef _WIN32
+
         // WinHttp doesn't share WinInet/MSIE's proxy settings and has its own,
         // but many users don't have properly configured both. Adopting proxy
         // settings like this in desktop software is recommended behavior, see
@@ -385,12 +393,9 @@ private:
                 c.set_proxy(uri(L"//" + std::wstring(ieConfig.lpszProxy)));
             }
         }
-    #endif
         return c;
     }
 
-private:
-#ifdef _WIN32
     static bool is_windows_xp()
     {
         OSVERSIONINFOEX info;