CURL ?
다양한 프로토콜을 지원하는 데이터 전송용 Command Line Tool 이다.
(Http, Https, FTP, SFTP, SMTP 등을 지원)
GET
$ curl -d "key1=value&key2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X GET http://localhost:8080/data"POST
# x-www-form-urlencoded
$ curl -H "Content-Type: application/x-www-form-urlencoded" -d "key1=value&key2=value2" -X POST http://localhost:8080/data"
# application/json
$ curl -H "Content-Type: application/json" -d '{"key1":"value", "key2":"value2"} -X POST http://localhost:8080/data"옵션 정리 http의 메소드를 지정 [ -X ]
$ curl -X [PUT|GET|POST] http://www.example.netresponse header 확인 [ -I, i ]
# 헤더만 출력
$ curl -I http://www.example.net
# header와 body 둘다 출력
$ curl -i http://www.example.netSSL 인증서 에러 무시 [ -k ]
$ curl -k https://www.example.netoutput [ -o ]
$ curl -o /dev/null http://www.example.net특정 포맷에 맞게 write [ -w ]
# status code 출력
$ curl -w '%{http_code}\n' http://www.example.net진척상황 표시하지 않기 [ -s ]
# 에러도 표시되지 않음
$ curl -s https://www.example.net
# 에러는 표시
$ curl -sS https://www.example.net프록시 이용시 [ -x, —proxy ]
$ curl --proxy <proxyip>:<port> http://www.example.net
$ curl -x <proxyip>:<port> http://www.example.net
$ curl -x <proxyip>:<port> --proxy-user <username>:<password> http://www.example.net
$ curl -x <username>:<password>@<proxyip>:<port> http://www.example.net최대접속시간제한을 설정 [ —connect-timeout ]
$ curl --connect-timeout 600 http://www.example.net