URL 기반으로 데이터를 웹(서버)로 전송하기 위한 명령줄 유틸리티다.
별도의 view나 툴 업시 직접 서버에 http request를 날리고 response를 확인 할 수 있다.
curl을 사용하면 HTTP, HTTPS, SCP, SFTP, FRP 등 다양한 프로토콜과 Proxy, Header, Cookie등 세부 옵션까지 쉽게 설정 할 수 있다.
현재 대부분의 리눅스 배포 환경에는 curl패키지가 미리 설치되어 있다.
시스템에 curl 패키지 설치되어 있는지 확이낳려면 콘솔을 열고 curl 을 입력하면 된다. curl이 설치된 경우 시스템에서 curl을 인쇄한다.
curl이 없으면 "sudo apt install curl"로 설치하면 된다.
curl [option][URL]
가장 감단한 형태는 'curl example.com'이다.
프로토콜을 지정하지 않은 경우 , curl은 사용할 프로토콜을 추측하려고 시도하며, 이 프로토콜은 HTTP로 기본 설정된다.
-X: http method를 get/post로 할건지 지정, 디폴트는 get
-H: http 헤더값
-d: http body값 or 함께 전달할 파라미터 값
-G: 전송할 사이트 url 및 ip 주소
-I: 사이트의 Header 정보만 가져오기
-i: 사이트의 Header와 바디 정보를 함께 가져오기
-u: 사용자의 정보
- Local - post
$ curl -X POST localhost:3000/apis/search?v=0.3.0 -H "Content-Type: application/json" -d '{"searchId": "test999991", "restaurantMenus": ["test1","test2","test3","test4"]}'
- Local - get
$ curl -G localhost:3000/apis/search? -H 'Content-type:application/json' -d 'v=0.3.0' -d 'f=finder' -d 'searchId=test999991’ -v
- Server - post
$ curl -X POST https://naver.com/apis/search?v=0.3.0 -H "Content-Type: application/json" -d '{"searchId": "test6161990", "restaurantMenus": ["test1","test2","test3","test4"]}'
- Server - get
$ curl -G https://naver.com/apis/search? -H 'Content-type:application/json' -d 'v=0.3.0' -d 'f=finder' -d 'searchId=test6161990' -v
큰 도움이 되었습니다, 감사합니다.