Expand HTTP method docs

* mention `POST` without a body
* mention `GET` with a body
* mention custom method names
* include examples for default `GET`/`POST`
This commit is contained in:
Jakub Roztocil 2021-10-03 03:05:37 +02:00 committed by GitHub
parent 7388401134
commit a6c70334cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -256,7 +256,53 @@ Which looks similar to the actual `Request-Line` that is sent:
DELETE /delete HTTP/1.1
```
When the `METHOD` argument is omitted from the command, HTTPie defaults to either `GET` (with no request data) or `POST` (with request data).
In addition to the standard methods (`GET`, `POST`, `HEAD`, `PUT`, `PATCH`, `DELETE`, etc.), you can use custom method names, for example:
```bash
$ http AHOY pie.dev/post
```
There are no restrictions regarding which request methods can include a body. You can send an empty `POST` request:
```bash
$ http POST pie.dev/post
```
You can also make `GET` requests contaning a body:
```bash
$ http GET pie.dev/get hello=world
```
### Optional `GET` and `POST`
The `METHOD` argument is optional, and when you dont specify it, HTTPie defaults to:
* `GET` for requests without a body
* `POST` for requests with body
Here we dont specify any request data, so both commands will send the same `GET` request:
```bash
$ http GET pie.dev/get
```
```bash
$ http pie.dev/get
```
Here, on the other hand, we do have some data, so both commands will make the same `POST` request:
```
$ http POST pie.dev/post hello=world
```
```bash
$ http pie.dev/post hello=world
```
## Request URL