Skip to content

Commit

Permalink
Pre-release: updated copyrighted content
Browse files Browse the repository at this point in the history
  • Loading branch information
cclilshy committed Nov 13, 2024
1 parent 562907b commit a0407bf
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 262 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php declare(strict_types=1);

/*
* Copyright (c) 2023-2024.
*
Expand Down
24 changes: 12 additions & 12 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

namespace Ripple\Http;

use Co\IO;
use GuzzleHttp\Psr7\Response;
use Psr\Http\Message\RequestInterface;
use Ripple\Http\Client\Capture;
use Ripple\Http\Client\Connection;
use Ripple\Http\Client\ConnectionPool;
use Ripple\Socket\Tunnel\Http;
use Ripple\Socket\Tunnel\Socks5;
use Ripple\Socket;
use Ripple\Stream\Exception\ConnectionException;
use Ripple\Tunnel\Http;
use Ripple\Tunnel\Socks5;
use Throwable;

use function getenv;
Expand Down Expand Up @@ -145,28 +145,28 @@ private function pullConnection(string $host, int $port, bool $ssl, int $timeout
switch ($parse['scheme']) {
case 'socks':
case 'socks5':
$tunnelSocket = Socks5::connect("tcp://{$parse['host']}:{$parse['port']}", $payload)->getSocketStream();
$ssl && IO::Socket()->enableSSL($tunnelSocket, $timeout);
$tunnelSocket = Socks5::connect("tcp://{$parse['host']}:{$parse['port']}", $payload)->getSocket();
$ssl && $tunnelSocket->enableSSL();
$connection = new Connection($tunnelSocket);
break;
case 'http':
$tunnelSocket = Http::connect("tcp://{$parse['host']}:{$parse['port']}", $payload)->getSocketStream();
$ssl && IO::Socket()->enableSSL($tunnelSocket, $timeout);
$tunnelSocket = Http::connect("tcp://{$parse['host']}:{$parse['port']}", $payload)->getSocket();
$ssl && $tunnelSocket->enableSSL();
$connection = new Connection($tunnelSocket);
break;
case 'https':
$tunnel = IO::Socket()->connectWithSSL("tcp://{$parse['host']}:{$parse['port']}", $timeout);
$tunnelSocket = Http::connect($tunnel, $payload)->getSocketStream();
$ssl && IO::Socket()->enableSSL($tunnelSocket, $timeout);
$tunnel = Socket::connectWithSSL("tcp://{$parse['host']}:{$parse['port']}", $timeout);
$tunnelSocket = Http::connect($tunnel, $payload)->getSocket();
$ssl && $tunnelSocket->enableSSL();
$connection = new Connection($tunnelSocket);
break;
default:
throw new ConnectionException('Unsupported proxy protocol', ConnectionException::CONNECTION_ERROR);
}
} else {
$connection = $ssl
? new Connection(IO::Socket()->connectWithSSL("ssl://{$host}:{$port}", $timeout))
: new Connection(IO::Socket()->connect("tcp://{$host}:{$port}", $timeout));
? new Connection(Socket::connectWithSSL("ssl://{$host}:{$port}", $timeout))
: new Connection(Socket::connect("tcp://{$host}:{$port}", $timeout));
}
}

Expand Down
28 changes: 12 additions & 16 deletions src/Client/Capture/ServerSentEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Exception;
use GuzzleHttp\Psr7\Response;
use Iterator;
use Ripple\Coroutine;
use Ripple\Coroutine\Coroutine;
use Ripple\Http\Client\Capture;
use Throwable;

Expand All @@ -35,9 +35,14 @@
*/
class ServerSentEvents extends Capture
{
/*** @var \Closure|null */
public Closure|null $onEvent = null;
/*** @var \Closure|null */
public Closure|null $onComplete = null;
/*** @var array */
protected array $iterators = [];
/*** @var string */
private string $status = 'pending';

/*** @var string */
private string $buffer = '';

Expand Down Expand Up @@ -138,15 +143,6 @@ public function processContent(string $content): void
}
}

/*** @return string */
public function getStatus(): string
{
return $this->status;
}

/*** @var array */
protected array $iterators = [];

/**
* @return iterable
*/
Expand Down Expand Up @@ -238,9 +234,9 @@ public function rewind(): void
};
}

/*** @var \Closure|null */
public Closure|null $onEvent = null;

/*** @var \Closure|null */
public Closure|null $onComplete = null;
/*** @return string */
public function getStatus(): string
{
return $this->status;
}
}
Loading

0 comments on commit a0407bf

Please sign in to comment.