Skip to content

bitjerry/Headers

Repository files navigation

Headers


Download Version Star APM

This tool assists programmers in quickly handling browser request message information.

Read in other languages: English | 简体中文

Installation


Get from Marketplace

Features


  1. Quickly format headers or cookies text copied from the browser into JSON format.
  2. Generate request code based on curl commands copied from the browser.
  3. 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.

  1. Copy the message headers from the browser or select existing code, then right-click on "headers" or "cookies" in the code editing area.
  2. The plugin automatically generates the corresponding content in JSON format and pastes it into the cursor position or replaces the current text.

Header Conversion

Generate Request Code

Generate request code based on curl commands.
The plugin provides three default code generation scripts: aiohttp, request, okhttp.

  1. Copy the curl command. When pasting in IntelliJ IDEA, right-click on "headers" in the context menu corresponding to the curl code generation script.
  2. The plugin automatically inserts the code at the cursor position.

Curl Command Generation

Custom Code Generation Script

Customize the curl request conversion script to generate any request code.

  1. 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.
  2. Open Settings -> Tools -> Headers, add a script to the left script list, and paste the script created earlier into the right editor.
  3. You can now right-click on "headers" in IDEA to see the corresponding code generation script for curl command transformation.
  4. 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.

Custom Script

FAQ

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. Method not found, undefined, or syntax errors?
  6. 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