Vscode-restclient: Response body should not be parsed for "204 No Content" code

Created on 29 May 2020  路  3Comments  路  Source: Huachao/vscode-restclient

  • REST Client Version: 0.23.2
  • VSCode Version: 1.45.1
  • OS Version: macOS 10.15.5

Prerequisites:

  1. REST API which responds to POST verb with 204 No Content code, Content-Type: application/json headers and empty body.

Steps to Reproduce:

  1. Create the following REST request:
POST http://host.tld/some-api HTTP/1.1
Content-Type: application/json

{}
  1. Execute the request.

Actual behaviour:

  1. A warning message in the lower right corner stating: The content type of response is application/json, while response body is not a valid json string.
  2. The request is executed successfully.

Expected behaviour:

  1. No warning is displayed.
  2. The request is executed successfully.

Comments:

As per RFC 2616, the server can respond with both Content-Type header and empty body under 204 HTTP code. Please see these links for details:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.2.5
http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7.1

Suggested changes:

  1. Parse response body only if the response code supposes presence of that body.
bug

All 3 comments

@YBogomolov nice catch, I have fixed this issue and will publish it in the next release.

@YBogomolov you can verify this in the latest version 0.24.0

@Huachao It works as intended, thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zdila picture zdila  路  6Comments

rohitkrishna094 picture rohitkrishna094  路  3Comments

rohitkrishna094 picture rohitkrishna094  路  3Comments

AresAndy picture AresAndy  路  3Comments

Marvin-Brouwer picture Marvin-Brouwer  路  3Comments