AnWeber / httpbook

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
https://httpyac.github.io/
MIT License
57 stars 4 forks source link

No request body requests break the following blocks #75

Closed UndefinedOffset closed 1 year ago

UndefinedOffset commented 1 year ago

As a follow on to #74 I noticed that if you have a request with no body i.e image

You end up with the following written to the file system:

/*
## Test
*/
/*
#### Test 1
*/
GET https://example.com/api/auth/logout HTTP/1.1
X-Apitoken: {{api_token}}
/*
#### Test 2
*/
###
{{@response
    global.api_token = JSON.parse(response.body).token;
}}
POST https://example.com/api/auth/login HTTP/1.1
Content-Type: application/json
{
    "email": "{{httpbook_email}}",
    "pwd": "{{httpbook_password}}"
}

Which after re-opening results in: image

AnWeber commented 1 year ago

a workaround would be to add an empty line after X-Apitoken.

GET https://example.com/api/auth/logout HTTP/1.1
X-Apitoken: {{api_token}}

/*
#### Test 2
*/

Looks like an error in the vscode-httpyac parser. I'm trying to fix it. I'm a fan of blank lines between blocks, so I've had more errors that way.

UndefinedOffset commented 1 year ago

Ya that fixes it when editing outside but the minute it's saved by the httpbook editor it gets removed

AnWeber commented 1 year ago

The cause was the way I built the cells. The idea was to use the symbols of the Outline View and create the cells with them. Unfortunately, blank lines are not assigned to an outline and are therefore swallowed. I now iterate directly over the source lines and determine the associated outline to then be able to determine what type of cell is needed. Additionally, there was an error that the initial comment was interpreted as an extension of the url line. For this I have published an update of vscode-httpyac that fixes this (https://github.com/AnWeber/httpyac/commit/e25c04ba191eb64f8288b3b091ccf05e94a60919).