mirror of
https://codeberg.org/vlw/curl.git
synced 2026-04-13 10:49:39 +02:00
In this PR we add a new directly to store the files used with curl. We also put the response body and headers into files now instead of echoing them to the console. This makes them easier to read, and we can pretty-print JSON response bodies with proper syntax highlighting (and more). Since we have a few files now, I've also added an "init.sh" file that can be used to create the necessary files on first load. Reviewed-on: https://codeberg.org/vlw/curl/pulls/3 Co-authored-by: vlw <victor@vlw.se> Co-committed-by: vlw <victor@vlw.se>
78 lines
No EOL
2.1 KiB
Markdown
78 lines
No EOL
2.1 KiB
Markdown

|
|
|
|

|
|
|
|
|
|
This is a wrapper for curl written in bash designed to be used along with Visual Studio Code.
|
|
|
|
> Mom, can we get Postman?
|
|
>
|
|
> We've got Postman at home!
|
|
>
|
|
> [\- Source](https://knowyourmeme.com/memes/we-have-food-at-home)
|
|
|
|
[Here is a simpler version of this script that prints the response body directly to the console](/vlw/curl/src/tag/1.1.0)
|
|
|
|
# Get started
|
|
Clone this repo
|
|
```sh
|
|
git clone https://codeberg.org/vlw/curl --depth 1
|
|
```
|
|
|
|
This script uses separate files in the `curl/` directory for various request options. You can generate these files on first load by running the init script.
|
|
```sh
|
|
./init.sh
|
|
```
|
|
|
|
> [!Note]
|
|
> If you're using this with VSCode, drag each file into the workspace area where you want it to display. You of course don't have to follow the layout in the screenshot above.
|
|
|
|
# Files
|
|
This script reads or writes values in these files to construct a request or show a response from a request.
|
|
|
|
## Disable SSL peer validation
|
|
You can disable SSL peer validation (for self-signed certificates etc.) by creating an empty file `disable_peer_validation` in the base directory of this repo.
|
|
```sh
|
|
touch disable_peer_validation
|
|
```
|
|
|
|
## Request
|
|
### `curl/req_params.txt`
|
|
URL search parameters. Each newline is treated as a separate search parameter.
|
|
```
|
|
foo=bar
|
|
fizz=buzz
|
|
```
|
|
|
|
### `curl/req_body.json`
|
|
JSON request body that will be sent with all requests (except `GET`). Leave empty to send nothing.
|
|
```json
|
|
{
|
|
"request_body_parameter": "request_body_value"
|
|
}
|
|
```
|
|
|
|
### `curl/req_headers.json`
|
|
Key-value JSON object of optional request headers.
|
|
```json
|
|
{
|
|
"X-Header-Name": "Header value"
|
|
}
|
|
```
|
|
|
|
## Response
|
|
### `curl/resp_headers.txt`
|
|
A raw output of the response headers from the last request
|
|
|
|
### `curl/resp_body.txt`
|
|
The raw response body received from the last request
|
|
|
|
### `curl/resp_body.json`
|
|
The raw response body parsed into- and automatically pretty-printed JSON
|
|
|
|
# Make a request
|
|
Run the `curl.sh` file from your shell and pass it two parametes for URL and request method.
|
|
|
|
```sh
|
|
./curl.sh https://example.com GET
|
|
``` |