[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 1f09fd3 59/69: Review commentary section before a
From: |
João Távora |
Subject: |
[elpa] externals/eglot 1f09fd3 59/69: Review commentary section before another review cycle |
Date: |
Fri, 22 Jun 2018 11:55:04 -0400 (EDT) |
branch: externals/eglot
commit 1f09fd332efc0f202d0816005e133be11923debf
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Review commentary section before another review cycle
* jsonrpc.el (jsonrpc-connection-send): Send Content-Type header.
---
jsonrpc.el | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/jsonrpc.el b/jsonrpc.el
index db99f16..0c38257 100644
--- a/jsonrpc.el
+++ b/jsonrpc.el
@@ -36,7 +36,7 @@
;; To model this agnosticism, jsonrpc.el uses objects derived from a
;; base `jsonrpc-connection' class, which is "abstract" or "virtual"
;; (in modern OO parlance) and represents the connection to the remote
-;; JSON endpoint. We can define two interfaces:
+;; JSON endpoint. Around thsi calss can define two interfaces:
;;
;; 1) A user interface to the JSONRPC _application_, whereby the
;; application uses the `jsonrpc-connection' object to communicate
@@ -57,25 +57,26 @@
;; forwarded instead. A suitable error reponse is also sent if the
;; function error unexpectedly with any other error.
;;
-;; 2) A inheritance-based interface for building arbitrary JSONPRPC
-;; _transport implementations_.
+;; 2) A inheritance-based interface to the JSONPRPC _transport
+;; implementations_, whereby `jsonrpc-connection' is subclassed.
;;
-;; For initiating contacts to the endpoint and replying to it, a
-;; subclass of `jsonrpc-connection' must implement
+;; For initiating contacts to the endpoint and replying to it, that
+;; subclass `jsonrpc-connection' must implement
;; `jsonrpc-connection-send'. Likewise, for handling remotely
;; initiated contacts, it must arrange for the dispatcher functions
;; held in `jsonrpc--request-dispatcher' and
;; `jsonrpc--notification-dispatcher' to be called when appropriate,
;; i.e. when noticing a new JSONRPC message on the wire. Optionally
-;; it should implement `jsonrpc-shutdown' and `jsonrpc-running-p'.
+;; it should implement `jsonrpc-shutdown' and `jsonrpc-running-p' if
+;; these concepts apply to the transport.
;;
-;; For convenience, jsonrpc.el comes built-in with
+;; For convenience, jsonrpc.el comes built-in with a
;; `jsonrpc-process-connection' subclass for talking to local
;; subprocesses (through stdin/stdout) and TCP hosts using sockets.
;; This uses some basic HTTP-style enveloping headers for JSON objects
;; sent over the wire. For an example of an application using this
-;; transport scheme on top of JSONRPC, see for example the Language
-;; Server Protocol
+;; transport scheme on top of JSONRPC, see the Language Server
+;; Protocol
;; (https://microsoft.github.io/language-server-protocol/specification).
;; `jsonrpc-process-connection' also implements `jsonrpc-shutdown',
;; `jsonrpc-running-p'.
@@ -170,7 +171,8 @@ notifications. CONN, METHOD and PARAMS are the same as in
;;; API mandatory
(cl-defgeneric jsonrpc-connection-send (conn &key id method params result
error)
- "Send a JSONRPC message to connection CONN.")
+ "Send a JSONRPC message to connection CONN.
+ID, METHOD, PARAMS, RESULT and ERROR. ")
;;; API optional
(cl-defgeneric jsonrpc-shutdown (conn)
@@ -391,11 +393,15 @@ connection object, called when the process dies .")
,@(when params `(:params ,params))
,@(when result `(:result ,result))
,@(when error `(:error ,error))))
- (json (jsonrpc--json-encode message)))
- (process-send-string (jsonrpc--process connection)
- (format "Content-Length: %d\r\n\r\n%s"
- (string-bytes json)
- json))
+ (json (jsonrpc--json-encode message))
+ (headers
+ `(("Content-Length" . ,(string-bytes json))
+ ("Content-Type" . "application/vscode-jsonrpc; charset=utf-8"))))
+ (process-send-string
+ (jsonrpc--process connection)
+ (cl-loop for (header . value) in headers
+ concat (concat header ": " value "\r\n") into header-section
+ finally return (format "%s\r\n%s" header-section json)))
(jsonrpc--log-event connection message 'client)))
(defun jsonrpc-process-type (conn)
- [elpa] externals/eglot 69a622a 64/69: Fix some typos, (continued)
- [elpa] externals/eglot 69a622a 64/69: Fix some typos, João Távora, 2018/06/22
- [elpa] externals/eglot 7371f68 57/69: * jsonrpc.el: Rewrite commentary., João Távora, 2018/06/22
- [elpa] externals/eglot 6531c8b 58/69: Merge branch 'master' into jsonrpc-refactor, João Távora, 2018/06/22
- [elpa] externals/eglot 59cc3fb 61/69: jsonrpc-connection-receive is now a public convenience function, João Távora, 2018/06/22
- [elpa] externals/eglot d371f05 49/69: Request dispatcher's return value determines response, João Távora, 2018/06/22
- [elpa] externals/eglot 0f20fdf 68/69: Tiny README.md change, João Távora, 2018/06/22
- [elpa] externals/eglot cef3c29 22/69: Heroically merge master into jsonrpc-refactor (using imerge), João Távora, 2018/06/22
- [elpa] externals/eglot a4441c6 37/69: Merge master into jsonrpc-refactor (using imerge), João Távora, 2018/06/22
- [elpa] externals/eglot 0e44b27 27/69: jsonrpc.el uses classes and generic functions, João Távora, 2018/06/22
- [elpa] externals/eglot 856a224 62/69: Simplify jsonrpc-connection-send, João Távora, 2018/06/22
- [elpa] externals/eglot 1f09fd3 59/69: Review commentary section before another review cycle,
João Távora <=
- [elpa] externals/eglot 8fda30c 67/69: Merge master into jsonrpc-refactor (using imerge), João Távora, 2018/06/22
- [elpa] externals/eglot 7f4e273 31/69: Merge master into jsonrpc-refactor (using imerge), João Távora, 2018/06/22
- [elpa] externals/eglot 4525eca 43/69: Support json.c. API purely based on classes, João Távora, 2018/06/22
- [elpa] externals/eglot bb60c0c 21/69: Rename jrpc.el to jsonrpc.el, João Távora, 2018/06/22
- [elpa] externals/eglot 46e6107 54/69: Reshuffle definitions inside jsonrpc.el, João Távora, 2018/06/22
- [elpa] externals/eglot 6f1ecc6 28/69: Merge branch use-eieio-server-defclass into jsonrpc-refactor, João Távora, 2018/06/22
- [elpa] externals/eglot 10559a5 56/69: Shuffle definitions around again, João Távora, 2018/06/22
- [elpa] externals/eglot b3c8b59 02/69: Refactor JSON-RPC lib jrpc.el from eglot.el, João Távora, 2018/06/22
- [elpa] externals/eglot 1ec47fb 51/69: Remove connection grabbing antics from jsonrpc.el, João Távora, 2018/06/22
- [elpa] externals/eglot f385d9c 69/69: Merge branch 'jsonrpc-refactor', bump version to 1.0, João Távora, 2018/06/22