JetBrains / JetBrains/http-request-in-editor-spec
Enable saving the response to a file after running the request handler
- Dominant language
- No language data
- Stars
- 152
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
By default the response is saved in a file `{{$historyFolder}}/{{ISO 8601 date-time}}.{{responseStatus}}.json`
Currently I am able to override it like this:
```
###
GET http://host/request
>>! {{$historyFolder}}/my-request.v{{apiVersion}}.json
```
Where apiVersion comes from the selected environment. However, I am also interested in putting the response's status code in the filename (in the same way as the default), but I don't seem to be able to make it work like below, because the response is saved to a file _before_ the response handler script is ran. This means `responseStatus` contains either nothing, or the previous request's response status.
```
###
GET http://host/request
> {%
client.global.set("responseStatus", response.status.toString());
%}
>>! {{$historyFolder}}/my-request.v{{apiVersion}}.{{responseStatus}}.json
```
**Other thoughts:**
- An alternative solution for this specific use case may be to add a `$responseStatus` variable (next to `$timestamp`, `$randomInt`, etc.) although that variable's value would depend on a changing context, which doesn't seem to be the intention of those existing variables. It seems to me the original proposal would bring more flexibility.
- The execution order of saving/handling could even be made dependent on the order of the commands as they appear after the request in the `.http`-file. So by placing the `> file.js` or `> {% /* ... */ %}` response handler _after_ the saving instruction (if both are specified), the current/old behavior can still be attained.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the response-saving step and response-handler execution order described in the issue. Compare post-handler filename evaluation with the proposed command-order alternative; done means the specification defines a consistent order and allows the response status to be used when naming the saved file.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100