Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"rize/uri-template": "^0.4.1 || ^0.3"
},
"require-dev": {
"clue/caret-notation": "^0.2",
"clue/tar-react": "^0.2",
"phpunit/phpunit": "^9.6 || ^8.5 || ^5.7 || ^4.8.36",
"react/async": "^4.3 || ^3 || ^2"
Expand Down
12 changes: 5 additions & 7 deletions examples/archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@

$tar = new Clue\React\Tar\Decoder();

// use caret notation for any control characters except \t, \r and \n
$caret = new Clue\CaretNotation\Encoder("\t\r\n");

$tar->on('entry', function ($header, React\Stream\ReadableStreamInterface $file) use ($caret) {
$tar->on('entry', function ($header, React\Stream\ReadableStreamInterface $file) {
// write each entry to the console output
echo '########## ' . $caret->encode($header['filename']) . ' ##########' . PHP_EOL;
$file->on('data', function ($chunk) use ($caret) {
echo $caret->encode($chunk);
echo '########## ' . $header['filename'] . ' ##########' . PHP_EOL;
Comment thread
clue marked this conversation as resolved.
$file->on('data', function ($chunk) {
// escape control characters except \t, \r and \n
echo addcslashes($chunk, "\x00..\x08\x0b\x0c\x0e..\x1f\x7f");
});
});

Expand Down
8 changes: 3 additions & 5 deletions examples/attach-stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@

$client = new Clue\React\Docker\Client();

// use caret notation for any control characters except \t, \r and \n
$caret = new Clue\CaretNotation\Encoder("\t\r\n");

$stream = $client->containerAttachStream($container, true, true);

$stream->on('data', function ($data) use ($caret) {
echo $caret->encode($data);
$stream->on('data', function ($data) {
// escape control characters except \t, \r and \n
echo addcslashes($data, "\x00..\x08\x0b\x0c\x0e..\x1f\x7f");
});

$stream->on('error', function (Exception $e) {
Expand Down
8 changes: 3 additions & 5 deletions examples/logs-stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@

$client = new Clue\React\Docker\Client();

// use caret notation for any control characters except \t, \r and \n
$caret = new Clue\CaretNotation\Encoder("\t\r\n");

$stream = $client->containerLogsStream($container, true, true, true, 0, false, 100);

$stream->on('data', function ($data) use ($caret) {
echo $caret->encode($data);
$stream->on('data', function ($data) {
// escape control characters except \t, \r and \n
echo addcslashes($data, "\x00..\x08\x0b\x0c\x0e..\x1f\x7f");
});

$stream->on('error', function (Exception $e) {
Expand Down
4 changes: 1 addition & 3 deletions examples/logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// $ php examples/logs.php foo
// $ docker rm foo

use Clue\CaretNotation\Encoder;
use Clue\React\Docker\Client;

require __DIR__ . '/../vendor/autoload.php';
Expand All @@ -22,8 +21,7 @@ function ($logs) {
echo 'Received the following logs:' . PHP_EOL;

// escape control characters (dumping logs of vi/nano etc.)
$caret = new Clue\CaretNotation\Encoder("\t\r\n");
echo $caret->encode($logs);
echo addcslashes($logs, "\x00..\x08\x0b\x0c\x0e..\x1f\x7f");
},
function (Exception $e) use ($container) {
echo <<<EOT
Expand Down