reactphp-docker
reactphp-docker copied to clipboard
Adds Support for TCP Hijack in execStartStream
- Expected to fix #33
- As suggested in the Docker API documentation on https://docs.docker.com/engine/api/v1.24/#42-hijacking
- Depends on https://github.com/reactphp/http/pull/382 (Not sure how
clue/reactphp-buzzcomes to play)
Summary of changes
- Adds
$hijakparameter toexectStartsStream - Configures the browser based on
$hijak
Example Usage
$client->execCreate('bash', 'bash', true, true, true, true)
->then(function($info) use ($client) {
$client->execStartStream($info['Id'], true,'stderr', true)->then(function (UpgradedResponse $e) use ($deferred) {
$stream = $e->getConnection();
$stream->on('data', function ($chunk) {
echo $chunk;
});
$stream->write("ls\r"); // list directories
});
});
@clue I'm thinking 🤔 since the Hijak feature is still part of the /exec/{exec}/start API and only surfaces when the Hijak is configured, we can just have the execStartStream return a DuplexStreamInterface which, as you've said, will cover for the ReadableStreamInterface also.
I initially added execStartStreamUpgrade as a public interface, but I noticed the same parameters are being passed for it as well as execStartStream which is more like some repetition there. Which lead me to merge the 2 methods.