Browse Source

change size attribute destination, add line attribute

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

34
src/Server.php

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

Loading…
Cancel
Save