Search code examples
phpcurlphp-curl

What is the php-curl equivalent of "curl --raw"?


From curl's man page:

--raw (HTTP) When used, it disables all internal HTTP decoding of content or transfer encodings and instead makes them passed on unaltered, raw.

Is there a way to get the same behavior in PHP, using curl functions / setopt?

CURLOPT_HTTP_CONTENT_DECODING is not enough, as it still parses chunked responses.

I tried using CURLOPT_HTTP_CONTENT_DECODING on a "Transfer-encoding: chunked" response, but it still parses the chunks, so I guess that's not the right option.

NOTE for moderators thinking this is a duplicate of this, here I'm talking about RESPONSE encoding, not REQUEST encoding... that's what "--raw" is about.


Solution

  • By looking at the extension's source code I just found that the undocumented option "CURLOPT_HTTP_TRANSFER_DECODING", set to false, does the trick.