curl.md 1.4 KB

curl

๋ฐ์ดํ„ฐ๋ฅผ ์„œ๋ฒ„์—์„œ ํ˜น์€ ์„œ๋ฒ„๋กœ ์ „์†ก. HTTP,FTP ๋ฐ POP3๋ฅผ ํฌํ•จํ•œ ๋Œ€๋ถ€๋ถ„์˜ ํ”„๋กœํ† ์ฝœ ์ง€์›. ๋” ๋งŽ์€ ์ •๋ณด: https://curl.se/docs/manpage.html.

  • URL์˜ ๋‚ด์šฉ์„ ํŒŒ์ผ๋กœ ๋‹ค์šด๋กœ๋“œ:

curl {{http://example.com}} --output {{ํŒŒ์ผ๋ช…}}

  • URL์— ํ‘œ์‹œ๋œ ํŒŒ์ผ ๋ช…์œผ๋กœ ์ถœ๋ ฅ์„ ์ €์žฅํ•˜๊ณ  ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ:

curl --remote-name {{http://example.com/filename}}

  • [L]์œ„์น˜ ๋ฆฌ๋‹ค์ด๋ ‰์…˜ ํ›„ ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ํ•˜๊ณ , ์ž๋™์œผ๋กœ ์ด์ „ ํŒŒ์ผ [C]์ „์†ก(์žฌ์‹œ์ž‘):

curl --fail --remote-name --location --continue-at - {{http://example.com/filename}}

  • ์–‘์‹ ์ธ์ฝ”๋”ฉ ๋ฐ์ดํ„ฐ ์ „์†ก(application/x-www-form-urlencoded์œ ํ˜•์˜ POST ์š”์ฒญ):

curl --data {{'name=bob'}} {{http://example.com/form}}

  • ์‚ฌ์šฉ์ž ์ง€์ • HTTP ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ถ”๊ฐ€ ํ—ค๋”๋กœ ์š”์ฒญ ์ „์†ก:

curl --header {{'X-My-Header: 123'}} --request {{PUT}} {{http://example.com}}

  • ์ ์ ˆํ•œ ์ปจํ…์ธ  ์œ ํ˜• ํ—ค๋”๋ฅผ ์ง€์ •ํ•˜์—ฌ JSON ํฌ๋ฉง์œผ๋กœ ๋ฐ์ดํ„ฐ ์ „์†ก:

curl --data {{'{"name":"bob"}'}} --header {{'Content-Type: application/json'}} {{http://example.com/users/123}}

  • ์„œ๋ฒ„ ์ธ์ฆ์„ ์œ„ํ•œ ์‚ฌ์šฉ์ž ์ด๋ฆ„ ๋ฐ ๋น„๋ฐ€๋ฒˆํ˜ธ ์ „๋‹ฌ:

curl --user {{์‚ฌ์šฉ์ž ๋ช…}} {{http://example.com}}

  • ๋ฆฌ์†Œ์Šค์— ๋Œ€ํ•œ ํด๋ผ์ด์–ธํŠธ ์ธ์ฆ์„œ ๋ฐ ํ‚ค ์ „๋‹ฌ, ์ธ์ฆ์„œ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ ์Šคํ‚ต:

curl --cert {{ํด๋ผ์ด์–ธํŠธ.pem}} --key {{ํ‚ค.pem}} --insecure {{https://example.com}}