-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reintroduce WebsocketAcceptor interface
Provides separation between RequestHandler and the different purpose of these classes.
- Loading branch information
Showing
5 changed files
with
49 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Amp\Websocket\Server; | ||
|
||
use Amp\Http\Server\Request; | ||
use Amp\Http\Server\Response; | ||
|
||
interface WebsocketAcceptor | ||
{ | ||
/** | ||
* Respond to websocket handshake requests. | ||
* | ||
* If a websocket application doesn't wish to impose any special constraints on the | ||
* handshake it may use {@see Rfc6455Acceptor} to accept websocket requests on a | ||
* {@see Websocket} endpoint. | ||
* | ||
* Most web applications should check the `origin` header to restrict access, | ||
* as websocket connections aren't subject to browser's same-origin-policy. See | ||
* {@see AllowOriginAcceptor} for such an implementation. | ||
* | ||
* This method provides an opportunity to set application-specific headers, including | ||
* cookies, on the websocket response. Although any non-101 status code can be used | ||
* to reject the websocket connection, we generally recommended using a 4xx status | ||
* code that is descriptive of why the handshake was rejected. It is suggested that an | ||
* instance of {@see ErrorHandler} is used to generate such a response. | ||
* | ||
* The response provided by the upgrade handler is made available to | ||
* {@see WebsocketClientHandler::handleClient()}. | ||
* | ||
* @param Request $request The websocket HTTP handshake request. | ||
* | ||
* @return Response Return a response with a status code other than | ||
* {@link HttpStatus::SWITCHING_PROTOCOLS} to deny the handshake request. | ||
*/ | ||
public function handleHandshake(Request $request): Response; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters