HTTPie는 HTTP 명령줄 클라이언트입니다.
HTTPie는 테스팅, 디버깅 및 API 및 HTTP 서버와 상호 작용하도록 설계되었습니다. http 및 https 명령을 사용하면 임의의 HTTP 요청을 만들고 보낼 수 있습니다.
주요특징
- 직관적인 구문
- 형식 및 색상이 지정된 출력
- 내장 JSON 지원
- Form 및 file 업로드
- HTTPS, 프록시 및 인증
- 임의 요청 데이터
- 사용자 정의 헤더
- 영구 세션
- Wget과 유사한 다운로드
- Linux, macOS, Windows 및 FreeBSD 지원
- 플러그인
설치하기
Python 3.6 이상의 버전이 설치되어 있어야 합니다.python --version 명령어로 python 버전을 확인합니다.
아래 명령어로 httpie 를 설치합니다.
$ python3 -m pip install --upgrade pip wheel
$ python3 -m pip install httpie
Windows 에 설치
Chocolatey 로 설치합니다. chocolatey 설치는 chocolatey installation 를 참고합니다.
$ choco install httpie
# 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
예제
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
$ http -v pie.dev/get
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
HTTP method
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:
DELETE /delete HTTP/1.1
In addition to the standard methods (GET, POST, HEAD, PUT, PATCH, DELETE, etc.), you can use custom method names, for example:
$ http AHOY pie.dev/post
There are no restrictions regarding which request methods can include a body. You can send an empty POST request:
$ http POST pie.dev/post
You can also make GET requests contaning a body:
$ 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 body
- POST for requests with body
Here we don’t specify any request data, so both commands will send the same GET request:
$ http GET pie.dev/get
$ 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
$ http pie.dev/post hello=world
Request URL
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
Querystring parameters
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
URL shortcuts for localhost
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.
$ http :/foo
GET /foo HTTP/1.1
Host: localhost
$ http :3000/bar
GET /bar HTTP/1.1
Host: localhost:3000
$ http :
GET / HTTP/1.1
Host: localhost
'이것저것' 카테고리의 다른 글
SQLServer database 이동 (0) | 2022.01.25 |
---|---|
WSL2에 nginx 설치하기 (0) | 2022.01.23 |
curl (0) | 2022.01.18 |
Windows Powershell 항상 admin으로 실행하기 (0) | 2022.01.02 |
스택(Stack)과 힙(Heap) 차이점 (0) | 2022.01.02 |