unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* jsonrpc.el uses "Content-Length" headers which seem specific to LSP
@ 2023-10-18 23:17 Adam Porter
  2023-10-19  0:11 ` João Távora
  0 siblings, 1 reply; 6+ messages in thread
From: Adam Porter @ 2023-10-18 23:17 UTC (permalink / raw)
  To: João Távora; +Cc: emacs-devel

Hi João, et al,

In our work on hyperdrive.el (a new project currently packaged on NonGNU 
ELPA), we're beginning a refactor to use a JSON-RPC backend rather than 
the HTTP-based API we've been using.  In the process we've discovered 
that jsonrpc.el seems to hard-code the use of HTTP-style 
"Content-Length" headers.  These are required by LSP (obviously, one of 
the major use-cases for jsonrpc.el), however, as best we can tell, 
JSON-RPC itself does not mention the use of these headers.[0]  And, in 
fact, the RPC server we're connecting to does not expect them nor send 
them, and it fails when encountering them.

With jsonrpc.el being based on EIEIO and generic methods, we work around 
this easily enough by defining our own process connection type 
subclassing jsonrpc-process-connection with associated methods that omit 
the header-related code (not sending the header with requests, and not 
looking for one when parsing responses, just trying to parse the 
incoming text as JSON).  This seems to work well, and the code is 
pleasantly simple.

However, we wonder if jsonrpc.el is not quite as generic as it should 
be, i.e. whether the use of these HTTP-style headers should be done in a 
specific subclass rather than the jsonrpc-process-connection one, so 
that other, non-LSP JSON-RPC servers could be used more easily.  Would 
that be reasonable, or am I missing something (which wouldn't be 
surprising, as some of this is new territory for me)?

I hope I'm not retreading old ground by bringing this up; I searched the 
list and bug tracker but couldn't find anything relevant.

Thanks,
Adam

0: https://www.jsonrpc.org/specification



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-12-01  0:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-18 23:17 jsonrpc.el uses "Content-Length" headers which seem specific to LSP Adam Porter
2023-10-19  0:11 ` João Távora
2023-10-19 20:59   ` Adam Porter
2023-10-20  0:02     ` João Távora
2023-11-22 22:40       ` Adam Porter
2023-12-01  0:45         ` João Távora

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).