# HG changeset patch # User Bram Moolenaar # Date 1682431209 -7200 # Node ID 10a03ae8ba6013f3a3a9d98808a3b86b9e39b581 # Parent c6eab83d1ba9bd063a06cf05272add72f8272445 patch 9.0.1487: Content-type header for LSP channel not according to spec Commit: https://github.com/vim/vim/commit/c3eddd2068620ceb4e475961192c1d8cae3350cd Author: Yegappan Lakshmanan Date: Tue Apr 25 14:54:54 2023 +0100 patch 9.0.1487: Content-type header for LSP channel not according to spec Problem: Content-type header for LSP channel not according to spec. Solution: Use "vscode-jsonrpc" instead of "vim-jsonrpc". (Yegappan Lakshmanan, closes #12295) diff --git a/src/json.c b/src/json.c --- a/src/json.c +++ b/src/json.c @@ -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); diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -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) diff --git a/src/testdir/test_channel_lsp.py b/src/testdir/test_channel_lsp.py --- a/src/testdir/test_channel_lsp.py +++ b/src/testdir/test_channel_lsp.py @@ -35,7 +35,7 @@ class ThreadedTCPRequestHandler(socketse 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(socketse 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(socketse 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(socketse 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(socketse # 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')) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1487, +/**/ 1486, /**/ 1485,