Headers
This tool assists programmers in quickly handling browser request message information.
Read in other languages: English | 简体中文
Installation
Features
- Quickly format headers or cookies text copied from the browser into JSON format.
- Generate request code based on curl commands copied from the browser.
- Custom code generator.
Usage
Convert Request Headers
Quickly convert request headers, cookies, and formData to JSON format.
Can be directly used as a Python dictionary.
- Copy the message headers from the browser or select existing code, then right-click on "headers" or "cookies" in the code editing area.
- The plugin automatically generates the corresponding content in JSON format and pastes it into the cursor position or replaces the current text.
Generate Request Code
Generate request code based on curl commands.
The plugin provides three default code generation scripts: aiohttp, request, okhttp.
- Copy the curl command. When pasting in IntelliJ IDEA, right-click on "headers" in the context menu corresponding to the curl code generation script.
- The plugin automatically inserts the code at the cursor position.
Custom Code Generation Script
Customize the curl request conversion script to generate any request code.
- Use any editor to write a JavaScript script that must include a globally scoped
transform
function, taking a curl object as the only parameter and returning the generated code string.
- Open Settings -> Tools -> Headers, add a script to the left script list, and paste the script created earlier into the right editor.
- You can now right-click on "headers" in IDEA to see the corresponding code generation script for curl command transformation.
- All scripts will be continuously updated in this repository, and you can click here to get more scripts. If you have better suggestions, please submit an issue, and share your script.
FAQ
- Why can't my copied curl command be parsed or has missing parameters?
- The plugin's curl command parser doesn't support all parameters. It mainly focuses on curl commands from the browser. If you have specific requirements, feel free to raise an issue for enhancement.
Please select the bash format when copying curl commands from the browser.
- Is the generated code incorrect?
- The plugin's default scripts were tested with some examples from the curl documentation. However, due to the complexity of curl, there might be omissions or issues with generated code. You can modify the scripts to address any issues with the generated code.
- Why is the generated code format messy?
- Check if auto-formatting and maintaining indentation are enabled in the plugin options. If formatting fails, ensure that the corresponding language support plugin is installed in IDEA.
- Is the script execution slow?
- After each script modification, the initial execution might be slower, but subsequent executions will be faster due to the compilation cache.
- Method not found, undefined, or syntax errors?
- Why JavaScript and nashorn?
- JavaScript was chosen for code generation scripts due to its flexibility compared to template languages. For most users dealing with browser-requested data, JavaScript is more user-friendly.
Nashorn, while somewhat dated and criticized, is lightweight and sufficient for code generation. If you have better suggestions, feel free to raise an issue.
License
Apache 2.0 © bitjerry
2021/11/22
Mr.lin