Skip to content

Commit

Permalink
update Swoole Library in Swoole 5.0.1
Browse files Browse the repository at this point in the history
Signed-off-by: Demin Yin <[email protected]>
  • Loading branch information
deminy committed Nov 8, 2022
1 parent bb0cc67 commit f9cdf7b
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 46 deletions.
4 changes: 2 additions & 2 deletions src/swoole_library/src/core/Coroutine/FastCGI/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function translateRequest($userRequest): HttpRequest
$server = $userRequest->server;
$headers = $userRequest->header;
$pathInfo = $userRequest->server['path_info'];
$pathInfo = '/' . (ltrim($pathInfo, '/'));
$pathInfo = '/' . ltrim($pathInfo, '/');
if (strlen($this->index) !== 0) {
$extension = pathinfo($pathInfo, PATHINFO_EXTENSION);
if (empty($extension)) {
Expand Down Expand Up @@ -167,7 +167,7 @@ public function translateResponse(HttpResponse $response, $userResponse): void

public function pass($userRequest, $userResponse): void
{
if (!($userRequest instanceof HttpRequest)) {
if (!$userRequest instanceof HttpRequest) {
$request = $this->translateRequest($userRequest);
} else {
$request = $userRequest;
Expand Down
42 changes: 21 additions & 21 deletions src/swoole_library/src/core/Curl/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,17 +482,17 @@ private function setOption(int $opt, $value): bool
case CURLOPT_PRIVATE:
$this->info['private'] = $value;
break;
/*
* Ignore options
*/
/*
* Ignore options
*/
case CURLOPT_VERBOSE:
// trigger_error('swoole_curl_setopt(): CURLOPT_VERBOSE is not supported', E_USER_WARNING);
case CURLOPT_SSLVERSION:
case CURLOPT_NOSIGNAL:
case CURLOPT_FRESH_CONNECT:
/*
* From PHP 5.1.3, this option has no effect: the raw output will always be returned when CURLOPT_RETURNTRANSFER is used.
*/
/*
* From PHP 5.1.3, this option has no effect: the raw output will always be returned when CURLOPT_RETURNTRANSFER is used.
*/
case CURLOPT_BINARYTRANSFER: /* TODO */
case CURLOPT_DNS_USE_GLOBAL_CACHE:
case CURLOPT_DNS_CACHE_TIMEOUT:
Expand All @@ -507,9 +507,9 @@ private function setOption(int $opt, $value): bool
case CURLOPT_PROXYHEADER:
case CURLOPT_HTTPPROXYTUNNEL:
break;
/*
* SSL
*/
/*
* SSL
*/
case CURLOPT_SSL_VERIFYHOST:
break;
case CURLOPT_SSL_VERIFYPEER:
Expand All @@ -532,9 +532,9 @@ private function setOption(int $opt, $value): bool
case CURLOPT_SSLKEYPASSWD:
$this->clientOptions[Constant::OPTION_SSL_PASSPHRASE] = $value;
break;
/*
* Http POST
*/
/*
* Http POST
*/
case CURLOPT_POST:
$this->method = 'POST';
break;
Expand All @@ -544,18 +544,18 @@ private function setOption(int $opt, $value): bool
$this->method = 'POST';
}
break;
/*
* Upload
*/
/*
* Upload
*/
case CURLOPT_SAFE_UPLOAD:
if (!$value) {
trigger_error('swoole_curl_setopt(): Disabling safe uploads is no longer supported', E_USER_WARNING);
return false;
}
break;
/*
* Http Header
*/
/*
* Http Header
*/
case CURLOPT_HTTPHEADER:
if (!is_array($value) and !is_iterable($value)) {
trigger_error('swoole_curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER argument', E_USER_WARNING);
Expand Down Expand Up @@ -602,9 +602,9 @@ private function setOption(int $opt, $value): bool
case CURLOPT_FAILONERROR:
$this->failOnError = $value;
break;
/*
* Http Cookie
*/
/*
* Http Cookie
*/
case CURLOPT_COOKIE:
$this->setHeader('Cookie', $value);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/swoole_library/src/core/FastCGI/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Request extends Message
public function __toString(): string
{
$body = $this->getBody();
$beginRequestFrame = new BeginRequest(FastCGI::RESPONDER, ($this->keepConn ? FastCGI::KEEP_CONN : 0));
$beginRequestFrame = new BeginRequest(FastCGI::RESPONDER, $this->keepConn ? FastCGI::KEEP_CONN : 0);
$paramsFrame = new Params($this->getParams());
$paramsEofFrame = new Params();
if (empty($body)) {
Expand Down
1 change: 1 addition & 0 deletions src/swoole_library/src/core/NameResolver/Consul.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace Swoole\NameResolver;

use Swoole\NameResolver;

use function Swoole\Coroutine\Http\get;
use function Swoole\Coroutine\Http\request;

Expand Down
1 change: 1 addition & 0 deletions src/swoole_library/src/core/Process/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Swoole\Process;

use Swoole\Constant;

use function Swoole\Coroutine\run;

class Manager
Expand Down
1 change: 1 addition & 0 deletions src/swoole_library/src/core/Server/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Swoole\Server;
use Swoole\Timer;

use function Swoole\Coroutine\go;

class Helper
Expand Down
44 changes: 22 additions & 22 deletions src/swoole_library/src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,28 @@ function swoole_table(int $size, string $fields): Swoole\Table
$type = $_f->get(1)->trim();

switch ($type) {
case 'i':
case 'int':
$table->column($name, Swoole\Table::TYPE_INT);
break;
case 'f':
case 'float':
$table->column($name, Swoole\Table::TYPE_FLOAT);
break;
case 's':
case 'string':
if ($_f->count() < 3) {
throw new RuntimeException('need to give string length');
}
$length = intval($_f->get(2)->trim()->toString());
if ($length <= 0) {
throw new RuntimeException("invalid string length[{$length}]");
}
$table->column($name, Swoole\Table::TYPE_STRING, $length);
break;
default:
throw new RuntimeException("unknown field type[{$type}]");
break;
case 'i':
case 'int':
$table->column($name, Swoole\Table::TYPE_INT);
break;
case 'f':
case 'float':
$table->column($name, Swoole\Table::TYPE_FLOAT);
break;
case 's':
case 'string':
if ($_f->count() < 3) {
throw new RuntimeException('need to give string length');
}
$length = (int) $_f->get(2)->trim()->toString();
if ($length <= 0) {
throw new RuntimeException("invalid string length[{$length}]");
}
$table->column($name, Swoole\Table::TYPE_STRING, $length);
break;
default:
throw new RuntimeException("unknown field type[{$type}]");
break;
}
}

Expand Down

0 comments on commit f9cdf7b

Please sign in to comment.