oliora / ppconsul

C++ client for Consul (http://consul.io)
Boost Software License 1.0
152 stars 57 forks source link

ppconsul with HTTP/2 #74

Open kolomparrudi opened 2 years ago

kolomparrudi commented 2 years ago

Hi,

We have upgraded libcurl and now it supports HTTP/2 protocol. After the upgrade ppconsul fails if I try to loads keys or items with BadException. The reason of the failure is the HTTP response did not match with http/2 response (HTTP/2 200).

As a short term solution I made this small change to force HTTP 1.1:

--- a/src/curl/http_client.cpp
+++ b/src/curl/http_client.cpp
@@ -80,6 +80,7 @@ namespace ppconsul { namespace curl {

         size_t headerCallback(char *ptr, size_t size_, size_t nitems, void *outputResponse_)
         {
+
             const auto size = size_ * nitems;
             auto outputResponse = reinterpret_cast<CurlHttpClient::GetResponse *>(outputResponse_);

@@ -236,6 +237,7 @@ namespace ppconsul { namespace curl {
             setopt(CURLOPT_SSL_VERIFYSTATUS, 1l);
 #endif
         }
+        setopt(CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     }

     CurlHttpClient::~CurlHttpClient() = default;

Regards,