reactphp-docker icon indicating copy to clipboard operation
reactphp-docker copied to clipboard

Adds Support for TCP Hijack in execStartStream

Open bosunski opened this issue 5 years ago • 1 comments

  • 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-buzz comes to play)

Summary of changes

  • Adds $hijak parameter to exectStartsStream
  • 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
                });
            });

bosunski avatar Jul 27 '20 21:07 bosunski

@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.

bosunski avatar Aug 20 '20 12:08 bosunski