Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added FileHeader support with @@ syntax #762

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mafshin
Copy link

@mafshin mafshin commented Feb 1, 2021

I added support for specifying file specific headers with @@ prefix (#737 ).

The file headers are processed based on the position of http request so that any file header above the request is automatically added to the list of request headers.

Also variable expansion in file headers are supported.

Sample usage:

@url  = https://jsonplaceholder.typicode.com/todos/1
@@Content-Type: application/json

### Request 1 with Content-Type header
GET {{url}}

### new header
@token = myAuthToken
@@Authorization: Bearer {{token}}


### Request 2 with Content-Type, Auhtorization and Accept-Encoding headers
GET {{url}}
Accept-Encoding: gzip

@mafshin
Copy link
Author

mafshin commented Feb 14, 2021

@Huachao this feature makes the .http request file much smaller and more readable specially when you have several default headers for a service.

The main other benefit of having these default variables as part of request file instead of user settings is that you can have them versioned in source control and share them with team as API is evolving.

@guillaume86
Copy link

I'm interested in this, any news regarding this PR?
Repeating the same headers every request lowers the signal/noise ratio a lot in http files.
(a special baseURL variable would also be nice but it's out of scope of this PR)

@mafshin
Copy link
Author

mafshin commented Apr 13, 2022

@Huachao no intention to merge this pull request or a similar implementaion?

Currently the request in .http files occupy multiple lines so this feature can greatly minimze the number of lines and makes finding the request much much easier.

Specially since there can be a .http file per Api and there exist common headers among each Api requests, then this feature is a game-changer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants