Compare commits

..

No commits in common. "4236a4943a89dc8e1c1c2d30c31f09f80164ec17" and "5854ed1b32be470b2ca9c126681fa4b417b94d37" have entirely different histories.

5 changed files with 277 additions and 653 deletions

View File

@ -113,7 +113,8 @@ foreach (page ${project_MAN_PAGES})
endforeach (page) endforeach (page)
# CPack # CPack
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "A shell for JSON-RPC 2.0") set (CPACK_PACKAGE_DESCRIPTION_SUMMARY
"A shell for running JSON-RPC 2.0 queries")
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch") set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch")
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>") set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>")
set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") set (CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")

View File

@ -2,25 +2,23 @@ json-rpc-shell
============== ==============
:compact-option: :compact-option:
'json-rpc-shell' is a shell for running JSON-RPC 2.0 queries. 'json-rpc-shell' is a simple shell for running JSON-RPC 2.0 queries.
This software was originally created as a replacement for This software has been created as a replacement for the following shell, which
http://software.dzhuvinov.com/json-rpc-2.0-shell.html[a different one] made by is written in Java: http://software.dzhuvinov.com/json-rpc-2.0-shell.html
Vladimir Dzhuvinov, in order to avoid Java, but has evolved since.
Features Features
-------- --------
In addition to most of the features provided by its predecessor, you will get In addition to most of the features provided by Vladimir Dzhuvinov's shell
the following niceties: you get the following niceties:
- configurable JSON syntax highlight, which with prettyprinting turned on - configurable JSON syntax highlight, which with prettyprinting turned on
helps you make sense of the results significantly helps you make sense of the results significantly
- 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
- WebSocket (RFC 6455) can also be used as a transport rather than HTTP - WebSockets (RFC 6455) can also be used as a transport rather than HTTP
- even Language Server Protocol servers may be launched as a slave command - support for method name tab completion using OpenRPC discovery
- support for method name tab completion using OpenRPC discovery or file input
Documentation Documentation
------------- -------------

View File

@ -6,11 +6,11 @@ json-rpc-shell(1)
Name Name
---- ----
json-rpc-shell - a shell for JSON-RPC 2.0 json-rpc-shell - a simple JSON-RPC 2.0 shell
Synopsis Synopsis
-------- --------
*json-rpc-shell* [_OPTION_]... { _ENDPOINT_ | _COMMAND_ [_ARG_]... } *json-rpc-shell* [_OPTION_]... _ENDPOINT_
Description Description
----------- -----------
@ -80,11 +80,6 @@ Protocol
Call "rpc.discover" upon start-up in order to pull in OpenRPC data for Call "rpc.discover" upon start-up in order to pull in OpenRPC data for
tab completion of method names. If a path is given, it is read from a file. tab completion of method names. If a path is given, it is read from a file.
*-e*, *--execute*::
Rather than an _ENDPOINT_, accept a command line to execute and communicate
with using the JSON-RPC 2.0 protocol variation used in the Language Server
Protocol.
Program information Program information
~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
*-h*, *--help*:: *-h*, *--help*::
@ -116,11 +111,11 @@ requests, it is often convenient or even necessary to run a full text editor
in order to construct complex objects or arrays, and may even be used to import in order to construct complex objects or arrays, and may even be used to import
data from elsewhere. You can launch an editor for the current request using data from elsewhere. You can launch an editor for the current request using
the M-e key combination. Both *readline*(3) and *editline*(7) also support the M-e key combination. Both *readline*(3) and *editline*(7) also support
multiline editing natively, press either M-Enter or 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.
WebSocket WebSockets
~~~~~~~~~ ~~~~~~~~~~
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

File diff suppressed because it is too large Load Diff

View File

@ -525,11 +525,11 @@ fcgi_muxer_push (struct fcgi_muxer *self, const void *data, size_t len)
} }
/// @} /// @}
// --- WebSocket --------------------------------------------------------------- // --- WebSockets --------------------------------------------------------------
/// @defgroup WebSocket /// @defgroup WebSockets
/// @{ /// @{
// WebSocket isn't CGI-compatible, therefore we must handle the initial HTTP // WebSockets aren'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 WebSocket frames WS_HANDLER_OPEN, ///< Parsing WebSockets 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 WebSocket // Check if we can actually upgrade the protocol to WebSockets
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 WebSocket" }, { "port_ws", NULL, "Port to bind for WebSockets" },
{ "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;
} }
// --- WebSocket client handler ------------------------------------------------ // --- WebSockets client handler -----------------------------------------------
struct client_ws struct client_ws
{ {
struct client client; ///< Parent class struct client client; ///< Parent class
struct ws_handler handler; ///< WebSocket connection handler struct ws_handler handler; ///< WebSockets connection handler
}; };
static bool static bool