1
- Socket Client
2
- =============
1
+ Socket Client (deprecated)
2
+ ==========================
3
3
4
4
The socket client uses the stream extension from PHP, which is integrated into
5
5
the core.
6
6
7
+ This client only implements the PHP-HTTP synchronous interface, which has been
8
+ superseded by PSR-18. Use one of the PSR-18 clients instead.
9
+
7
10
Features
8
11
--------
9
12
@@ -21,7 +24,23 @@ To install the Socket client, run:
21
24
22
25
$ composer require php-http/socket-client
23
26
24
- .. include :: includes/install-message-factory.inc
27
+ This client does not come with a PSR-7 implementation out of the box, so you have
28
+ to install one as well (for example `Guzzle PSR-7 `_):
29
+
30
+ .. code-block :: bash
31
+
32
+ $ composer require guzzlehttp/psr7
33
+
34
+ In order to provide full interoperability, message implementations are accessed
35
+ through :ref: `factories <message-factory >`. Message factories for
36
+ `Laminas Diactoros `_ (and its abandoned predecessor `Zend Diactoros `_),
37
+ `Guzzle PSR-7 `_ and `Slim PSR-7 `_ are available in the
38
+ :doc: `message </message >` component:
39
+
40
+ .. code-block :: bash
41
+
42
+ $ composer require php-http/message
43
+
25
44
26
45
Usage
27
46
-----
@@ -49,8 +68,8 @@ The available options are:
49
68
:write_buffer_size: When sending the request we need to buffer the body, this option specify the size of this buffer, default is 8192,
50
69
if you are sending big file with your client it may be interesting to have a bigger value in order to increase performance.
51
70
52
- As an example someone may want to pass a client certificate when using the ssl, a valid configuration for this
53
- use case would be::
71
+ As an example someone may want to pass a client certificate when using the ssl,
72
+ a valid configuration for this use case would be::
54
73
55
74
use Http\Client\Socket\Client;
56
75
@@ -65,13 +84,20 @@ use case would be::
65
84
66
85
.. warning ::
67
86
68
- This client assumes that the request is compliant with HTTP 2.0, 1.1 or 1.0 standard. So a request without a ``Host `` header, or
69
- with a body but without a ``Content-Length `` will certainly fail.
70
- To make sure all requests will be sent out correctly, we recommend to use the ``PluginClient `` with the following plugins:
87
+ This client assumes that the request is compliant with HTTP 2.0, 1.1 or 1.0
88
+ standard. So a request without a ``Host `` header, or with a body but
89
+ without a ``Content-Length `` will certainly fail. To make sure all requests
90
+ will be sent out correctly, we recommend to use the ``PluginClient `` with
91
+ the following plugins:
71
92
72
93
* ``ContentLengthPlugin `` sets the correct ``Content-Length `` header, or decorate the stream to use chunked encoding
73
94
* ``DecoderPlugin `` decodes encoding coming from the response (chunked, gzip, deflate and compress)
74
95
75
96
:doc: `Read more on plugins </plugins/introduction >`
76
97
77
98
.. include :: includes/further-reading-sync.inc
99
+
100
+ .. _Guzzle PSR-7 : https://github.com/guzzle/psr7
101
+ .. _Laminas Diactoros : https://github.com/laminas/laminas-diactoros
102
+ .. _Slim PSR-7 : https://github.com/slimphp/Slim-Psr7
103
+ .. _Zend Diactoros : https://github.com/zendframework/zend-diactoros
0 commit comments