Skip to content

Commit

Permalink
update: 支持多种客户ID传输方式
Browse files Browse the repository at this point in the history
  • Loading branch information
NHZEX committed May 23, 2024
1 parent c996cde commit cedc044
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,21 @@ private function onRequest(Request $request, Response $response): void
$contentType = \explode(';', $contentType)[0];
$contentType = \trim($contentType);

$clientId = \trim($path, '/');
if (isset($header['x-socket-log-clientid'])) {
$clientId = \trim($header['x-socket-log-clientid']);
} elseif (isset($request->get['clientId'])) {
$clientId = \trim($request->get['clientId']);
} else {
$clientId = \trim($path, '/');
}

if ($method !== 'POST'
|| empty($contentType)
|| empty($clientId)
|| \strlen($clientId) > 128
|| !\in_array($contentType, $this->allowContentTypes, true)
) {
$this->logger->warning("receive[#{$request->fd}] invalid request: {$path}");
$this->logger->warning("receive[#{$request->fd}] invalid request: " . ($path === $clientId ? $clientId : $path));
$response->status(426, 'Not Acceptable');
$response->end();
return;
Expand Down

0 comments on commit cedc044

Please sign in to comment.