Patch 9.0.1487
Problem:    Content-type header for LSP channel not according to spec.
Solution:   Use "vscode-jsonrpc" instead of "vim-jsonrpc". (Yegappan
            Lakshmanan, closes #12295)
Files:      src/json.c, src/testdir/test_channel.vim,
            src/testdir/test_channel_lsp.py


*** ../vim-9.0.1486/src/json.c  2023-03-04 20:47:32.304617857 +0000
--- src/json.c  2023-04-25 14:53:17.566916932 +0100
***************
*** 103,111 ****
      ga_append(&ga, NUL);
  
      ga_init2(&lspga, 1, 4000);
      vim_snprintf((char *)IObuff, IOSIZE,
            "Content-Length: %u\r\n"
!           "Content-Type: application/vim-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);
--- 103,112 ----
      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/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);
*** ../vim-9.0.1486/src/testdir/test_channel.vim        2023-01-28 
19:18:56.725720605 +0000
--- src/testdir/test_channel.vim        2023-04-25 14:49:30.862921857 +0100
***************
*** 2670,2676 ****
    " " 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 ..= "\r\n"
    " let s ..= '{"method":"echo","jsonrpc":"2.0","params":{"m":"raw-message"}}'
    " call ch_sendraw(ch, s)
--- 2670,2676 ----
    " " Test for sending a raw message
    " let g:lspNotif = []
    " let s = "Content-Length: 62\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)
*** ../vim-9.0.1486/src/testdir/test_channel_lsp.py     2023-01-09 
16:25:55.570919210 +0000
--- src/testdir/test_channel_lsp.py     2023-04-25 14:49:30.862921857 +0100
***************
*** 35,41 ****
              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 += "\r\n"
          resp += s
          if self.debug:
--- 35,41 ----
              v['id'] = msgid
          s = json.dumps(v)
          resp = "Content-Length: " + str(len(s)) + "\r\n"
!         resp += "Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n"
          resp += "\r\n"
          resp += s
          if self.debug:
***************
*** 46,52 ****
          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 += "\r\n"
          resp += s
          self.request.sendall(resp.encode('utf-8'))
--- 46,52 ----
          v = 'wrong-payload'
          s = json.dumps(v)
          resp = "Content-Length: " + str(len(s)) + "\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,66 ****
  
      def send_empty_payload(self):
          resp = "Content-Length: 0\r\n"
!         resp += "Content-Type: application/vim-jsonrpc; charset=utf-8\r\n"
          resp += "\r\n"
          self.request.sendall(resp.encode('utf-8'))
  
--- 60,66 ----
  
      def send_empty_payload(self):
          resp = "Content-Length: 0\r\n"
!         resp += "Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n"
          resp += "\r\n"
          self.request.sendall(resp.encode('utf-8'))
  
***************
*** 71,77 ****
          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-Length: " + str(len(s)) + "\r\n"
          resp += "\r\n"
          resp += s
--- 71,77 ----
          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/vscode-jsonrpc; charset=utf-8\r\n"
          resp += "Content-Length: " + str(len(s)) + "\r\n"
          resp += "\r\n"
          resp += s
***************
*** 93,99 ****
          # 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 += "\r\n"
          resp += s
          self.request.sendall(resp.encode('utf-8'))
--- 93,99 ----
          # 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/vscode-jsonrpc; charset=utf-8\r\n"
          resp += "\r\n"
          resp += s
          self.request.sendall(resp.encode('utf-8'))
*** ../vim-9.0.1486/src/version.c       2023-04-24 22:41:48.438538780 +0100
--- src/version.c       2023-04-25 14:52:00.622917075 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1487,
  /**/

-- 
Clothes make the man.  Naked people have little or no influence on society.
                               -- Mark Twain (Samuel Clemens) (1835-1910)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230425135531.6B61E1C07C5%40moolenaar.net.

Raspunde prin e-mail lui