Giter Site home page Giter Site logo

Comments (6)

phoenixwade avatar phoenixwade commented on July 29, 2024

I'd be very interested in this, MLSGrid is only communicating on a compressed stream starting on Aug 14th.

from reso-webapi-client-php.

theodorebear avatar theodorebear commented on July 29, 2024

same! working with MLS Grid which requires compressed gzip.

from reso-webapi-client-php.

theodorebear avatar theodorebear commented on July 29, 2024

can anyone verify that #5 works?

from reso-webapi-client-php.

clauz avatar clauz commented on July 29, 2024

I forked this project for several reasons, this issue being one of them. I would be more than happy to push a PR.

from reso-webapi-client-php.

carterterryw avatar carterterryw commented on July 29, 2024

can anyone verify that #5 works?

I can verify that the modifications do in fact work for MLSGrid requests. The only other modification I had to do was to gzdecode() the returned data since for some reason that piece was not automatic.

from reso-webapi-client-php.

jaybeaton avatar jaybeaton commented on July 29, 2024

The simplest solution is to update the curl options to set CURLOPT_ACCEPT_ENCODING. If this is set to an empty string, curl will automatically send the appropriate header based on the supported algorithms and automatically decode the response.

Sets the contents of the Accept-Encoding: header sent in an HTTP request, and enables decoding of a response when a Content-Encoding: header is received.

libcurl potentially supports several different compressed encodings depending on what support that has been built-in.

To aid applications not having to bother about what specific algorithms this particular libcurl build supports, libcurl allows a zero-length string to be set ("") to ask for an Accept-Encoding: header to be used that contains all built-in supported encodings.

This is the only change required for it to work correctly with MLSGrid (and any others, I'd guess), and it does not cause any problems with our other RESO providers:

diff --git a/lib/HttpClient/CurlClient.php b/lib/HttpClient/CurlClient.php
index f27f4c98f..53da6c1bf 100644
--- a/lib/HttpClient/CurlClient.php
+++ b/lib/HttpClient/CurlClient.php
@@ -173,6 +173,7 @@ public function request($method, $absUrl, $headers, $params, $hasFile)
         $opts[CURLOPT_CONNECTTIMEOUT] = $this->connectTimeout;
         $opts[CURLOPT_TIMEOUT] = $this->timeout;
         $opts[CURLOPT_HEADERFUNCTION] = $headerCallback;
+        $opts[CURLOPT_ACCEPT_ENCODING] = '';
         if($headers) {
             $opts[CURLOPT_HTTPHEADER] = $headers;
         }

From the curl docs:

This option was called CURLOPT_ENCODING before 7.21.6

The specific libcurl you are using must have been built with zlib to be able to decompress gzip and deflate responses, with the brotli library to decompress brotli responses and with the zstd library to decompress zstd responses.

from reso-webapi-client-php.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.