memostack
article thumbnail
블로그를 이전하였습니다. 2023년 11월부터 https://bluemiv.tistory.com/에서 블로그를 운영하려고 합니다. 앞으로 해당 블로그의 댓글은 읽지 못할 수 도 있으니 양해바랍니다.
반응형

HTTPie는 기존 curl과 같이 HTTP 요청을 보낼때 사용하는 CLI 기반의 툴이다.

HTTPie

설치 방법

설치 방법은 공식 사이트에 가면 친절히 설명되어있다.

httpie.io/

 

HTTPie – command-line HTTP client for the API era

CLI HTTP that will make you smile. JSON and sessions support, syntax highlighting, wget-like downloads, plugins, and more.

httpie.io

 

Homebrew를 이용하여 설치하는 방법을 소개하면,

아래와 같이 명령어를 수행한다.

$ brew install httpie

 

설치 후 아래와 같이 명령어를 수행하여, 버전이 나오면 정상적으로 설치가 된것이다.

$ http --version
2.3.0

 

사용방법

사용방법을 간단히 소개하면

http <옵션> <메소드> <주소> <키=값> 과 같은 형태로 보낼 수 있다.

 

예를들면,

$ http -v GET httpbin.org/get

GET /get HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: httpbin.org
User-Agent: HTTPie/2.3.0



HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 297
Content-Type: application/json
Date: Tue, 01 Dec 2020 23:18:06 GMT
Server: gunicorn/19.9.0

{
    "args": {},
    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate",
        "Host": "httpbin.org",
        "User-Agent": "HTTPie/2.3.0",
        "X-Amzn-Trace-Id": "Root=1-5fc6cf2e-1bc143b4554f73c74e2343fd"
    },
    "origin": "121.168.215.76",
    "url": "http://httpbin.org/get"
}
$ http -f POST httpbin.org/post hello=World

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 487
Content-Type: application/json
Date: Tue, 01 Dec 2020 23:19:14 GMT
Server: gunicorn/19.9.0

{
    "args": {},
    "data": "",
    "files": {},
    "form": {
        "hello": "World"
    },
    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate",
        "Content-Length": "11",
        "Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
        "Host": "httpbin.org",
        "User-Agent": "HTTPie/2.3.0",
        "X-Amzn-Trace-Id": "Root=1-5fc6cf72-47c56c415932fa741879cc0c"
    },
    "json": null,
    "origin": "121.168.215.76",
    "url": "http://httpbin.org/post"
}
반응형
블로그를 이전하였습니다. 2023년 11월부터 https://bluemiv.tistory.com/에서 블로그를 운영하려고 합니다. 앞으로 해당 블로그의 댓글은 읽지 못할 수 도 있으니 양해바랍니다.
profile

memostack

@bluemiv_mm

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!