-
Notifications
You must be signed in to change notification settings - Fork 56
Document Socket client #72
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Further reading | ||
--------------- | ||
|
||
.. include:: includes/further-reading.inc | ||
|
||
* Read more about :doc:`promises </components/promise>` when using asynchronous | ||
requests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Further reading | ||
--------------- | ||
|
||
.. include:: includes/further-reading.inc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
* Use :ref:`plugins <plugins>` to customize the way HTTP requests are sent and | ||
responses processed by following redirects, adding Authentication or Cookie | ||
headers and more. | ||
* Learn how you can decouple your code from any PSR-7 implementation by using a | ||
:ref:`message factory <message-factory>`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,64 @@ | ||
Socket Client | ||
============= | ||
|
||
The socket client uses the stream extension from PHP, which is integrated into | ||
the core. | ||
|
||
Features | ||
-------- | ||
|
||
* TCP Socket Domain (``tcp://hostname:port``) | ||
* UNIX Socket Domain (``unix:///path/to/socket.sock``) | ||
* TLS / SSL encryption | ||
* Client Certificate (only for PHP > 5.6) | ||
|
||
Installation | ||
------------ | ||
|
||
To install the Socket client, run: | ||
|
||
.. code-block:: bash | ||
|
||
$ composer require php-http/socket-client | ||
|
||
Usage | ||
----- | ||
|
||
The Socket client needs a :ref:`message factory <message-factory>` in order to | ||
to work:: | ||
|
||
use Http\Client\Socket\Client; | ||
|
||
$options = []; | ||
$client = new Client($messageFactory, $options); | ||
|
||
The available options are: | ||
|
||
:remote_socket: Specify the remote socket where the library should send the request to | ||
|
||
* Can be a TCP remote: ``tcp://hostname:port`` | ||
* Can be a UNIX remote: ``unix:///path/to/remote.sock`` | ||
* Do not use a TLS/SSL scheme, this is handle by the SSL option. | ||
* If not set, the client will try to determine it from the request URI or host header. | ||
:timeout: Timeout in milliseconds for writing request and reading response on the remote | ||
:ssl: Activate or deactivate SSL/TLS encryption | ||
:stream_context_options: Custom options for the context of the stream. See `PHP stream context options <http://php.net/manual/en/context.php>`_. | ||
:stream_context_params: Custom parameters for the context of the stream. See `PHP stream context parameters <http://php.net/manual/en/context.params.php>`_. | ||
:write_buffer_size: When sending the request we need to buffer the body, this option specify the size of this buffer, default is 8192, | ||
if you are sending big file with your client it may be interesting to have a bigger value in order to increase performance. | ||
|
||
As an example someone may want to pass a client certificate when using the ssl, a valid configuration for this | ||
use case would be:: | ||
|
||
use Http\Client\Socket\Client; | ||
|
||
$options = [ | ||
'stream_context_options' => [ | ||
'ssl' => [ | ||
'local_cert' => '/path/to/my/client-certificate.pem' | ||
] | ||
] | ||
]; | ||
$client = new Client($messageFactory, $options); | ||
|
||
.. include:: includes/further-reading-sync.inc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _plugins: | ||
|
||
Plugins | ||
======= | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this option what needs to be used when connecting through a proxy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t know. @joelwurtz Wrote the original readme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this option is where the client needs to be connected to send Http Requests, don't know how it works if we have a proxy. This is mainly due to support unix socket domain transport, like for docker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And unix remote example is wrong, i must have been drunk when writing this :, it should be
unix:///path/to/remote.sock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.