From a6c70334cff98727adef1edff82e39410fa71c4d Mon Sep 17 00:00:00 2001 From: Jakub Roztocil Date: Sun, 3 Oct 2021 03:05:37 +0200 Subject: [PATCH] Expand HTTP method docs * mention `POST` without a body * mention `GET` with a body * mention custom method names * include examples for default `GET`/`POST` --- docs/README.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index ed315370..532cdd2d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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 don’t specify it, HTTPie defaults to: + +* `GET` for requests without a body +* `POST` for requests with body + +Here we don’t 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