httpbook icon indicating copy to clipboard operation
httpbook copied to clipboard

support multiple requests in same code cell

Open yanghua-ola opened this issue 3 years ago • 1 comments

Another great plugin from you! I am really impressed. However I faced a little problem. Here is my use case:

  1. run two requests in the same code cell
  2. render only response from the second request

FYI, the first request triggers a CI build and second request checks its results; it could be a common use case.

However it didn't work so well as is. I've tried:

  1. use httpbook with the VSCode built-in renderer, it displays response from both requests
  2. use httpbook with the httpBook - Monaco Editor Renderer, it displays response from first request and doesn't refresh after second request completes
  3. use @no-log on first request, now it breaks the variable reference doe.user and failes, however if I run it a second time, it seems able to resolve the variable somehow, from cached value maybe.

Below is a minimal example. It was really fun to use these plugins you've developed. I am not proficient in TS or VSCode plugin development; but let me see if I can get a grasp of them and contribute back.

###
@user = doe
@password = 12345678
# @name doe
GET https://httpbin.org/basic-auth/{{user}}/{{password}}
Authorization: Basic {{user}} {{password}}

###
# @ref doe
GET https://httpbin.org/basic-auth/{{doe.user}}worked/{{password}}
Authorization: Basic {{doe.user}}worked {{password}}

yanghua-ola avatar Nov 11 '21 08:11 yanghua-ola

Two Requests in same Code Cell will not work. After saving and reloading, the two requests are split into separate code cells. I would have to add a unique seaparator for httpbook and then the http files would not be compatible between the tools (cli, vscode-httpyac, httpbook). You could probably build it, but is that really useful.

That it does not work with @no-log is a bug. : https://github.com/AnWeber/httpyac/blob/a54df9fe1f041fb09f8a2bd9c0e2d7545c690477/src/utils/httpRegionUtils.ts#L66-L68

AnWeber avatar Nov 11 '21 09:11 AnWeber