본문 바로가기

Ubuntu/linux Command

Linux Command (httpie)

728x90

특징

  • curl과 비슷한 http 요청과 응답을 처리할 수 있는 도구.
  • request/response에 대한 format 적인 부분을 colorful하게 포맷을 변경해서 표시할 수 있음.  
  • json 지원 기능 내장
  • Form 과 file 업로드가 쉬움.
  • HTTP 인증 및 커스텀 헤더 설정 가능

 

설치

sudo apt install httpie    // Ubuntu  에서 설치하는 방밥

 

문법

http flag {METHOD} {URL} {ITEM}

 

Method :  HTTP Method(GET, POST, PUT, DELETE 등)을 의미하며 기본값으론 GET이 설정되어 있음.

URL :  대상 URL을 의미

ITEM : 추가적인 데이터값들(POST/JSON Body 등)

 

용례

http -a admin:64105379 http://127.0.0.1:8000/users/

 개발중인 restapi test 시 account (admin) 와  password (64105379) 를 실어 보내는 것임 

 

 

1)  -v  :  자세한 정보 출력

http -v httpie.org

 

2) --headers(-h)  :  헤더 정보만 출력 response debugging 시에 사용함

http --headers http://example.org

 

3) Json  type 으로 변환되어 전달

http PUT example.org name=Tom email=tom@example.org

 

4) Download

http --download example.org/file

 

5) HTTP Method

http DELETE example.org/todosList/7

 

6) HTTP Authentication

-a 옵션 뒤에 인증 정보를 전달

http -a username:password example.org

http -a username example.org
  //prompt 에서 암호를 입력

 

 

7) Custom Header 설정

Header:Value 문법을 사용하여 전송함