vscode-restclient icon indicating copy to clipboard operation
vscode-restclient copied to clipboard

Extra newline after body file doesn't respect Content-type charset

Open Exenum opened this issue 8 months ago • 3 comments

  • REST Client Version: 0.25.1
  • VSCode Version: 1.99.3
  • OS Version: Linux x64 6.14.2-arch1-1

Steps to Reproduce:

  1. Create the file "document.xml" with utf-16le encoding: <?xml version="1.0" encoding="utf-16le"?> <root> <node>value</node> </root>
  2. Use this command to send POST request to locally running HTTP server: POST http://127.0.0.1:8000 Content-type: text/xml; charset=UTF-8 < ./document.xml
  3. The HTTP server dumps the request headers, hexadecimal view of body received and body as text: Host: 127.0.0.1:8000 User-agent: vscode-restclient Content-type: text/xml; charset=utf-16le Content-length: 163 fffe3c003f0078006d006c002000760065007200730069006f006e003d00220031002e0030002200200065006e0063006f006400 69006e0067003d0022007500740066002d00310036006c00650022003f003e000a003c0072006f006f0074003e000a002000 2000200020003c006e006f00640065003e00760061006c00750065003c002f006e006f00640065003e000a003c002f0072006f00 6f0074003e000a000a <?xml version="1.0" encoding="utf-16le"?> <root> <node>value</node> </root>

The last byte of the body is the newline (0x0a - �) which restclient added without respecting the charset specified in Content-type header.

Exenum avatar Apr 21 '25 18:04 Exenum

In my case I'm posting a PNG and I get the same behavior, the content-length header is also set one byte larger than the file and a 0a byte is appended to the end.

  • VScodium version: 1.100.23258, 557d9224936804f4aeb93625d7a45c97113627e4
  • Rest client version: 0.25.1
  • OS: Arch linux, liquorix kernel 6.14.7-lqx1-1-lqx

davidpanic avatar May 22 '25 09:05 davidpanic

Oh, apparently the version published in the marketplace is not the latest one, open VSX has version 0.26.0 and that works correctly: https://open-vsx.org/extension/humao/rest-client

davidpanic avatar May 22 '25 09:05 davidpanic

I am also facing the same issue. 0.25.1 and 0.25.0 version has this issue. Was able to install 0.24.6 and get this issue to be resolved.

harishankar-gopalan avatar Jul 05 '25 02:07 harishankar-gopalan