WebSockets -> WebSocket
This is the correct name of the protocol, usage of the word "WebSockets" should be limited.
This commit is contained in:
parent
5854ed1b32
commit
01767198f2
|
@ -17,7 +17,7 @@ you get the following niceties:
|
||||||
- ability to pipe output through a shell command, so that you can view the
|
- ability to pipe output through a shell command, so that you can view the
|
||||||
results in your favourite editor or redirect them to a file
|
results in your favourite editor or redirect them to a file
|
||||||
- ability to edit the input line in your favourite editor as well with Alt+E
|
- ability to edit the input line in your favourite editor as well with Alt+E
|
||||||
- WebSockets (RFC 6455) can also be used as a transport rather than HTTP
|
- WebSocket (RFC 6455) can also be used as a transport rather than HTTP
|
||||||
- support for method name tab completion using OpenRPC discovery
|
- support for method name tab completion using OpenRPC discovery
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
|
|
|
@ -114,8 +114,8 @@ the M-e key combination. Both *readline*(3) and *editline*(7) also support
|
||||||
multiline editing natively, though you need to press C-v C-j in order to insert
|
multiline editing natively, though you need to press C-v C-j in order to insert
|
||||||
newlines.
|
newlines.
|
||||||
|
|
||||||
WebSockets
|
WebSocket
|
||||||
~~~~~~~~~~
|
~~~~~~~~~
|
||||||
The JSON-RPC 2.0 specification doesn't say almost anything about underlying
|
The JSON-RPC 2.0 specification doesn't say almost anything about underlying
|
||||||
transports. The way it's implemented here is that every request is sent as
|
transports. The way it's implemented here is that every request is sent as
|
||||||
a single text message. If it has an "id" field, i.e., it's not just
|
a single text message. If it has an "id" field, i.e., it's not just
|
||||||
|
|
|
@ -1108,7 +1108,7 @@ g_ctx;
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
// HTTP/S and WS/S require significantly different handling. While for HTTP we
|
// HTTP/S and WS/S require significantly different handling. While for HTTP we
|
||||||
// can just use the cURL easy interface, with WebSockets it gets a bit more
|
// can just use the cURL easy interface, with WebSocket it gets a bit more
|
||||||
// complicated and we implement it all by ourselves.
|
// complicated and we implement it all by ourselves.
|
||||||
//
|
//
|
||||||
// Luckily on a higher level the application doesn't need to bother itself with
|
// Luckily on a higher level the application doesn't need to bother itself with
|
||||||
|
@ -1404,12 +1404,12 @@ on_config_attribute_change (struct config_item *item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- WebSockets backend ------------------------------------------------------
|
// --- WebSocket backend -------------------------------------------------------
|
||||||
|
|
||||||
enum ws_handler_state
|
enum ws_handler_state
|
||||||
{
|
{
|
||||||
WS_HANDLER_CONNECTING, ///< Parsing HTTP
|
WS_HANDLER_CONNECTING, ///< Parsing HTTP
|
||||||
WS_HANDLER_OPEN, ///< Parsing WebSockets frames
|
WS_HANDLER_OPEN, ///< Parsing WebSocket frames
|
||||||
WS_HANDLER_CLOSING, ///< Closing the connection
|
WS_HANDLER_CLOSING, ///< Closing the connection
|
||||||
WS_HANDLER_CLOSED ///< Dead
|
WS_HANDLER_CLOSED ///< Dead
|
||||||
};
|
};
|
||||||
|
@ -1442,7 +1442,7 @@ struct ws_context
|
||||||
SSL_CTX *ssl_ctx; ///< SSL context
|
SSL_CTX *ssl_ctx; ///< SSL context
|
||||||
SSL *ssl; ///< SSL connection
|
SSL *ssl; ///< SSL connection
|
||||||
|
|
||||||
// WebSockets protocol handling:
|
// WebSocket protocol handling:
|
||||||
|
|
||||||
enum ws_handler_state state; ///< State
|
enum ws_handler_state state; ///< State
|
||||||
char *key; ///< Key for the current handshake
|
char *key; ///< Key for the current handshake
|
||||||
|
|
|
@ -525,11 +525,11 @@ fcgi_muxer_push (struct fcgi_muxer *self, const void *data, size_t len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
// --- WebSockets --------------------------------------------------------------
|
// --- WebSocket ---------------------------------------------------------------
|
||||||
/// @defgroup WebSockets
|
/// @defgroup WebSocket
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
// WebSockets aren't CGI-compatible, therefore we must handle the initial HTTP
|
// WebSocket isn't CGI-compatible, therefore we must handle the initial HTTP
|
||||||
// handshake ourselves. Luckily it's not too much of a bother with http-parser.
|
// handshake ourselves. Luckily it's not too much of a bother with http-parser.
|
||||||
// Typically there will be a normal HTTP server in front of us, proxying the
|
// Typically there will be a normal HTTP server in front of us, proxying the
|
||||||
// requests based on the URI.
|
// requests based on the URI.
|
||||||
|
@ -537,7 +537,7 @@ fcgi_muxer_push (struct fcgi_muxer *self, const void *data, size_t len)
|
||||||
enum ws_handler_state
|
enum ws_handler_state
|
||||||
{
|
{
|
||||||
WS_HANDLER_CONNECTING, ///< Parsing HTTP
|
WS_HANDLER_CONNECTING, ///< Parsing HTTP
|
||||||
WS_HANDLER_OPEN, ///< Parsing WebSockets frames
|
WS_HANDLER_OPEN, ///< Parsing WebSocket frames
|
||||||
WS_HANDLER_CLOSING, ///< Partial closure by us
|
WS_HANDLER_CLOSING, ///< Partial closure by us
|
||||||
WS_HANDLER_FLUSHING, ///< Just waiting for client EOF
|
WS_HANDLER_FLUSHING, ///< Just waiting for client EOF
|
||||||
WS_HANDLER_CLOSED ///< Dead, both sides closed
|
WS_HANDLER_CLOSED ///< Dead, both sides closed
|
||||||
|
@ -1110,7 +1110,7 @@ ws_handler_finish_handshake (struct ws_handler *self)
|
||||||
if (!connection || strcasecmp_ascii (connection, "Upgrade"))
|
if (!connection || strcasecmp_ascii (connection, "Upgrade"))
|
||||||
FAIL_HANDSHAKE (HTTP_400_BAD_REQUEST);
|
FAIL_HANDSHAKE (HTTP_400_BAD_REQUEST);
|
||||||
|
|
||||||
// Check if we can actually upgrade the protocol to WebSockets
|
// Check if we can actually upgrade the protocol to WebSocket
|
||||||
const char *upgrade = str_map_find (&self->headers, "Upgrade");
|
const char *upgrade = str_map_find (&self->headers, "Upgrade");
|
||||||
struct http_protocol *offered_upgrades = NULL;
|
struct http_protocol *offered_upgrades = NULL;
|
||||||
bool can_upgrade = false;
|
bool can_upgrade = false;
|
||||||
|
@ -1286,7 +1286,7 @@ static struct simple_config_item g_config_table[] =
|
||||||
{ "bind_host", NULL, "Address of the server" },
|
{ "bind_host", NULL, "Address of the server" },
|
||||||
{ "port_fastcgi", "9000", "Port to bind for FastCGI" },
|
{ "port_fastcgi", "9000", "Port to bind for FastCGI" },
|
||||||
{ "port_scgi", NULL, "Port to bind for SCGI" },
|
{ "port_scgi", NULL, "Port to bind for SCGI" },
|
||||||
{ "port_ws", NULL, "Port to bind for WebSockets" },
|
{ "port_ws", NULL, "Port to bind for WebSocket" },
|
||||||
{ "pid_file", NULL, "Full path for the PID file" },
|
{ "pid_file", NULL, "Full path for the PID file" },
|
||||||
// XXX: here belongs something like a web SPA that interfaces with us
|
// XXX: here belongs something like a web SPA that interfaces with us
|
||||||
{ "static_root", NULL, "The root for static content" },
|
{ "static_root", NULL, "The root for static content" },
|
||||||
|
@ -2452,12 +2452,12 @@ client_scgi_create (EV_P_ int sock_fd)
|
||||||
return &self->client;
|
return &self->client;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- WebSockets client handler -----------------------------------------------
|
// --- WebSocket client handler ------------------------------------------------
|
||||||
|
|
||||||
struct client_ws
|
struct client_ws
|
||||||
{
|
{
|
||||||
struct client client; ///< Parent class
|
struct client client; ///< Parent class
|
||||||
struct ws_handler handler; ///< WebSockets connection handler
|
struct ws_handler handler; ///< WebSocket connection handler
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
Loading…
Reference in New Issue