Windows 에 설치
Chocolatey 로 설치합니다. chocolatey 설치는 chocolatey installation 를 참고합니다.
# Upgrade httpie
$ choco upgrade httpie
Linux 에 설치
Debian and Ubuntu
$ apt update
$ apt upgrade httpie
Fedora
# Install httpie
$ dnf install httpie
# Upgrade httpie
$ dnf upgrade httpie
CentOS and RHEL
# Install httpie
$ yum install epel-release
$ yum install httpie
# Upgrade httpie
$ yum upgrade httpie
사용법
Synopsis:
$ http [flags] [METHOD] URL [ITEM [ITEM]]
Hello World:
$ https httpie.io/hello
옵션 정보를 http --help 명령어를 수행하면 볼 수 있습니다.
예제
Custom HTTP method, HTTP headers and JSON data:
$ http PUT pie.dev/put X-API-Token:123 name=John
Submitting forms:
$ http -f POST pie.dev/post hello=World
Build and print a request without sending it using offline mode:
$ http --offline pie.dev/post hello=offline
Use GitHub API to post a comment on an issue with authentication:
$ http -a USERNAME POST https://api.github.com/repos/httpie/httpie/issues/83/comments body='HTTPie is awesome! :heart:'
Upload a file using redirected input:
$ http pie.dev/post < files/data.json
Download a file and save it via redirected output:
$ http pie.dev/image/png > image.png
Download a file wget style:
$ http --download pie.dev/image/png
Use named sessions to make certain aspects of the communication persistent between requests to the same host:
$ http --session=logged-in -a username:password pie.dev/get API-Key:123
$ http --session=logged-in pie.dev/headers
Set a custom Host header to work around missing DNS records:
$ http localhost:8000 Host:example.com
The name of the HTTP method comes right before the URL argument:
$ http DELETE pie.dev/delete
Which looks similar to the actual Request-Line that is sent:
In addition to the standard methods (GET, POST, HEAD, PUT, PATCH, DELETE, etc.), you can use custom method names, for example:
There are no restrictions regarding which request methods can include a body. You can send an empty POST request:
You can also make GET requests contaning a body:
$ http GET pie.dev/get hello=world
The METHOD argument is optional, and when you don’t specify it, HTTPie defaults to:
- GET for requests without body
- POST for requests with body
Here we don’t specify any request data, so both commands will send the same GET request:
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
$ http pie.dev/post hello=world
The only information HTTPie needs to perform a request is a URL.
The default scheme is http:// and can be omitted from the argument:
$ http example.org
# => http://example.org
HTTPie also installs an https executable, where the default scheme is https://:
$ https example.org
# => https://example.org
If you find yourself manually constructing URLs with querystring parameters on the terminal, you may appreciate the param==value syntax for appending URL parameters.
With that, you don’t have to worry about escaping the & separators for your shell. Additionally, any special characters in the parameter name or value get automatically URL-escaped (as opposed to the parameters specified in the full URL, which HTTPie doesn’t modify).
$ http https://api.github.com/search/repositories q==httpie per_page==1
GET /search/repositories?q=httpie&per_page=1 HTTP/1.1
Additionally, curl-like shorthand for localhost is supported. This means that, for example, :3000 would expand to http://localhost:3000 If the port is omitted, then port 80 is assumed.
GET /foo HTTP/1.1
Host: localhost
GET /bar HTTP/1.1
Host: localhost:3000
GET / HTTP/1.1
Host: localhost