Skip to content

[HttpClient] Expanding on HTTP compression #17218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions http_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,6 @@ immediately instead of waiting to receive the response::
This component also supports :ref:`streaming responses <http-client-streaming-responses>`
for full asynchronous applications.

.. note::

HTTP compression and chunked transfer encoding are automatically enabled when
both your PHP runtime and the remote server support them.

Authentication
~~~~~~~~~~~~~~

Expand Down Expand Up @@ -758,6 +753,20 @@ When using this component in a full-stack Symfony application, this behavior is
not configurable and cURL will be used automatically if the cURL PHP extension
is installed and enabled. Otherwise, the native PHP streams will be used.

HTTP Compression
~~~~~~~~~~~~~~~~

A HTTP header ``Accept-Encoding: gzip`` is added automatically if ...

* cURL Client: ... cURL was compiled with ZLib support (see ``php --ri curl``)
* Native Http Client: ... `Zlib PHP extension`_ is installed

If the server does respond with a gzipped response, it's decoded transparently.

To disable HTTP compression, send an ``Accept-Encoding: identity`` HTTP header.

Chunked transfer encoding is enabled automatically if both your PHP runtime and the remote server supports it.

HTTP/2 Support
~~~~~~~~~~~~~~

Expand Down Expand Up @@ -1571,6 +1580,7 @@ test it in a real application::
}

.. _`cURL PHP extension`: https://www.php.net/curl
.. _`Zlib PHP extension`: https://www.php.net/zlib
.. _`PSR-17`: https://www.php-fig.org/psr/psr-17/
.. _`PSR-18`: https://www.php-fig.org/psr/psr-18/
.. _`HTTPlug`: https://github.com/php-http/httplug/#readme
Expand Down