]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1487: Content-type header for LSP channel not according to spec v9.0.1487
authorYegappan Lakshmanan <yegappan@yahoo.com>
Tue, 25 Apr 2023 13:54:54 +0000 (14:54 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 25 Apr 2023 13:54:54 +0000 (14:54 +0100)
Problem:    Content-type header for LSP channel not according to spec.
Solution:   Use "vscode-jsonrpc" instead of "vim-jsonrpc". (Yegappan
            Lakshmanan, closes #12295)

src/json.c
src/testdir/test_channel.vim
src/testdir/test_channel_lsp.py
src/version.c

index c1602c3d835a5d479fc732020203e5779717b0b7..acf7ac57cfeaa22b2be44396973349e99c248242 100644 (file)
@@ -103,9 +103,10 @@ json_encode_lsp_msg(typval_T *val)
     ga_append(&ga, NUL);
 
     ga_init2(&lspga, 1, 4000);
+    // Header according to LSP specification.
     vim_snprintf((char *)IObuff, IOSIZE,
            "Content-Length: %u\r\n"
-           "Content-Type: application/vim-jsonrpc; charset=utf-8\r\n\r\n",
+           "Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n\r\n",
            ga.ga_len - 1);
     ga_concat(&lspga, IObuff);
     ga_concat_len(&lspga, ga.ga_data, ga.ga_len);
index a6b25c9a7805f46cdd404d946c21fbe8f5d636e7..6be2137c36dda55731071e3f1a6797ad8b6a2527 100644 (file)
@@ -2670,7 +2670,7 @@ func LspTests(port)
   " " Test for sending a raw message
   " let g:lspNotif = []
   " let s = "Content-Length: 62\r\n"
-  " let s ..= "Content-Type: application/vim-jsonrpc; charset=utf-8\r\n"
+  " let s ..= "Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n"
   " let s ..= "\r\n"
   " let s ..= '{"method":"echo","jsonrpc":"2.0","params":{"m":"raw-message"}}'
   " call ch_sendraw(ch, s)
index 10b4fb43f34ba7a59b5a4478d95f6016cc677c89..dd107be157edaf80a5e593d130b3928fd1624cca 100644 (file)
@@ -35,7 +35,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
             v['id'] = msgid
         s = json.dumps(v)
         resp = "Content-Length: " + str(len(s)) + "\r\n"
-        resp += "Content-Type: application/vim-jsonrpc; charset=utf-8\r\n"
+        resp += "Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n"
         resp += "\r\n"
         resp += s
         if self.debug:
@@ -46,7 +46,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
         v = 'wrong-payload'
         s = json.dumps(v)
         resp = "Content-Length: " + str(len(s)) + "\r\n"
-        resp += "Content-Type: application/vim-jsonrpc; charset=utf-8\r\n"
+        resp += "Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n"
         resp += "\r\n"
         resp += s
         self.request.sendall(resp.encode('utf-8'))
@@ -60,7 +60,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
 
     def send_empty_payload(self):
         resp = "Content-Length: 0\r\n"
-        resp += "Content-Type: application/vim-jsonrpc; charset=utf-8\r\n"
+        resp += "Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n"
         resp += "\r\n"
         self.request.sendall(resp.encode('utf-8'))
 
@@ -71,7 +71,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
         resp = "Host: abc.vim.org\r\n"
         resp += "User-Agent: Python\r\n"
         resp += "Accept-Language: en-US,en\r\n"
-        resp += "Content-Type: application/vim-jsonrpc; charset=utf-8\r\n"
+        resp += "Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n"
         resp += "Content-Length: " + str(len(s)) + "\r\n"
         resp += "\r\n"
         resp += s
@@ -93,7 +93,7 @@ class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):
         # test for sending the http header without length
         v = {'jsonrpc': '2.0', 'id': msgid, 'result': resp_dict}
         s = json.dumps(v)
-        resp = "Content-Type: application/vim-jsonrpc; charset=utf-8\r\n"
+        resp = "Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n"
         resp += "\r\n"
         resp += s
         self.request.sendall(resp.encode('utf-8'))
index 7de60de7f1a6b0c253dfb13e06c20f11396971aa..bc271c8af755a6a79133b038103e8959377a77fc 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1487,
 /**/
     1486,
 /**/