Vscode-restclient: Requests on multiple lines stopped working.

Created on 12 Jun 2020  路  10Comments  路  Source: Huachao/vscode-restclient

  • REST Client Version: 0.24.0
  • VSCode Version: 1.47.0-insider
  • OS Version: Windows 10

Steps to Reproduce:

  1. Create a http file with a request on multiple lines
  2. Launch the request

Color syntaxing for the request will be fine, but the REST Client will add breaking lines symbols (%0D%0A) to the http request which will lead to a HTTP 400 bad request.

It is breaking all my existing http files. I tested again with the previous version of the extension and it's working fine.

Another impact of this issue is that when assigning a variable with the result of a request, the request fails when there is only a blank line to separate the request and the assignment (the assignment is added to the body of the request).

Most helpful comment

@TechWatching @reganheath @jthagesk @schmas I have fixed the first question that query string spread into multiple lines, really nice catch. For the second question, I have to say sorry that this is a breaking change in the request body parsing logic. Previously, we treat the request body range from the first non-empty line after headers to the first empty line. That means if the request body contains blank lines, only the first part will be treated as body, the rest will be just ignored. However, this will break some users that want to have blank lines in request body. So I did this change. Another reason is that I always wish users to define the file variables at the beginning of each request block(separated by ###). So what @TechWatching did to solve this is the right action. Sorry for the inconvenience. I will notify you all when a new release is available, I think this will be soon. Before that, you may have to downgrade the extension to version 0.23.2

All 10 comments

Another impact of this issue is that when assigning a variable with the result of a request, the request fails when there is only a blank line to separate the request and the assignment (the assignment is added to the body of the request).

The endpoints I am using can handle the %0D%0A's but this effect is really ruining my day :(

@TechWatching could you please also provide the sample http request for your second issue ?

Yes sure.
`POST https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/token HTTP/1.1
Content-type: application/x-www-form-urlencoded

grant_type=client_credentials
&client_id={{clientId}}
&client_secret={{clientSecret}}
&scope={{scope}}

@token={{auth.response.body.access_token}}`

It's a call to retrieve a token from Azure AD on a specific scope. Problem is that @token is separated from the request by a blank line. If I add a comment before it works. That could be okay I guess but that's a breaking change for a lot of people I think.

`POST https://login.microsoftonline.com/{{tenantId}}/oauth2/v2.0/token HTTP/1.1
Content-type: application/x-www-form-urlencoded

grant_type=client_credentials
&client_id={{clientId}}
&client_secret={{clientSecret}}
&scope={{scope}}

Set Token

@token={{auth.response.body.access_token}}`

@TechWatching @reganheath @jthagesk @schmas I have fixed the first question that query string spread into multiple lines, really nice catch. For the second question, I have to say sorry that this is a breaking change in the request body parsing logic. Previously, we treat the request body range from the first non-empty line after headers to the first empty line. That means if the request body contains blank lines, only the first part will be treated as body, the rest will be just ignored. However, this will break some users that want to have blank lines in request body. So I did this change. Another reason is that I always wish users to define the file variables at the beginning of each request block(separated by ###). So what @TechWatching did to solve this is the right action. Sorry for the inconvenience. I will notify you all when a new release is available, I think this will be soon. Before that, you may have to downgrade the extension to version 0.23.2

@TechWatching @reganheath @jthagesk @schmas @parannoide @Cujoko I have published the latest version 0.24.1, you can verify the fix. Sorry for the inconvenience.

As indicated in @Huachao's response, you should have ### before your line @token. It's a breaking change but not a bug

@mensand you have to add ### before file variables definition

@mensand you have to add ### before file variables definition

Thanx. We found out just before your reply that also works. But before the change it worked without the ###

Not quite working, but is working

###
GET /services/FinancialAnalysis
        ?limit=2
Host: {{hostURL}}

The above works fine, but once I put on HTTP/1.1 in the end, like

###
GET /services/FinancialAnalysis HTTP/1.1
        ?limit=2
Host: {{hostURL}}

It stops to working with multiple lines.

@parannoide The protocol version HTTP/1.1 should be put after the request URL, so here, it should be put after the last query params like following

GET /services/FinancialAnalysis
        ?limit=2. HTTP/1.1
Host: {{hostURL}}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mtxr picture mtxr  路  13Comments

symbioticKid picture symbioticKid  路  28Comments

Odonno picture Odonno  路  22Comments

jianwu picture jianwu  路  13Comments

heneds picture heneds  路  32Comments