Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
fix handler function response
Browse files Browse the repository at this point in the history
  • Loading branch information
yggverse committed Apr 25, 2024
1 parent 64a7bc3 commit 27a4dc5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ $server->start(
string $content,
string $request,
string $connect
) {
): ?string
{
printf(
'connection: %s request: %s',
$connect,
Expand All @@ -97,6 +98,8 @@ $server->start(
$content
);
}

return 'thank you!';
}
);
```
Expand Down
16 changes: 12 additions & 4 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ public function start(
false
);

fclose(
$incoming
);

if ($handler)
{
$response = call_user_func(
Expand All @@ -198,8 +194,20 @@ public function start(
$request,
$connect
);

if ($response)
{
fwrite(
$incoming,
$response
);
}
}

fclose(
$incoming
);

} while ($this->_live);
}

Expand Down

0 comments on commit 27a4dc5

Please sign in to comment.