CMD - Curl

anonymous·2021년 9월 29일
0

curl

  • 데이터 전송에 사용하는 CMD 도구
  • HTTP, HTTPS, FTP, FTPS, SFTP, IMAP, SMTP, POP3 등의 다양한 프로토콜 지원.
  • 네트워크 요청 디버깅시 사용
  • Linux, Mac, Windows에서 전부 사용 가능

1 Get HTTP Request

curl https://www.naver.com/

2 Get the HTTP response headers

By default the response headers are hidden in the output of curl. To show them, use the i option:

curl -i https://www.naver.com/
# Header 만 출력 (no response body)
curl -I https://www.naver.com/

3 HTTP POST request

The X option lets you change the HTTP method used. By default, GET is used, and it’s the same as writing

# application/x-www-form-urlencoded Content-Type is sent.
curl -d "option=value&something=anothervalue" -X POST https://www.naver.com/

4 HTTP POST request sending JSON

In this case you need to explicitly set the Content-Type header, by using the H option:

curl -d '{"option": "value", "something": "anothervalue"}' -H "Content-Type: application/json" -X POST https://www.naver.com/

디스크에 있는 JSON 파일 발송:

curl -d "@my-file.json" -X POST https://www.naver.com/

5 Store the response to a file

curl -o sitefile.html https://www.naver.com/

6 Request and Response 상세 확인

curl --verbose -I https://www.naver.com/

7 크롬 도구 사용

REF

https://flaviocopes.com/http-curl/

profile
기술블로거입니다

0개의 댓글