Browse Source

change size attribute destination, add line attribute

main 1.1.0
yggverse 7 months ago
parent
commit
2ad7d32751
  1. 34
      src/Server.php

34
src/Server.php

@ -7,12 +7,14 @@ class Server @@ -7,12 +7,14 @@ class Server
private string $_host;
private int $_port;
private int $_size;
private int $_line;
private bool $_live;
public function __construct(
string $host = '127.0.0.1',
int $port = 1915,
int $size = 1024,
int $size = 0,
int $line = 1024,
bool $live = true
) {
$this->setHost(
@ -27,6 +29,10 @@ class Server @@ -27,6 +29,10 @@ class Server
$size
);
$this->setLine(
$line
);
$this->setLive(
$live
);
@ -81,6 +87,18 @@ class Server @@ -81,6 +87,18 @@ class Server
$this->_size = $value;
}
public function getLine(): int
{
return $this->_line;
}
public function setLine(
int $value
): void
{
$this->_line = $value;
}
public function getLive(): bool
{
return $this->_live;
@ -130,9 +148,11 @@ class Server @@ -130,9 +148,11 @@ class Server
$request = fread(
$incoming,
$this->_size
$this->_line
);
$success = true;
$content = '';
do
@ -140,10 +160,17 @@ class Server @@ -140,10 +160,17 @@ class Server
$line = trim(
fread(
$incoming,
$this->_size
$this->_line
)
);
if ($this->_size && mb_strlen($content) > $this->_size)
{
$success = false;
break;
}
if ($line == '.')
{
break;
@ -166,6 +193,7 @@ class Server @@ -166,6 +193,7 @@ class Server
{
$response = call_user_func(
$handler,
$success,
$content,
$request,
$connect

Loading…
Cancel
Save