1 분 소요

기본 옵션

  1. -O / –remote-name
    • 원격 URL의 파일을 로컬 파일로 저장할 때 원본 파일 이름을 사용합니다.
      curl -O https://example.com/file.zip
      
  2. -L / –location
    • 서버가 리디렉션 응답을 보내면, 자동으로 새로운 URL을 따라갑니다.
      curl -L http://example.com
      
  3. -o / –output [file]
    • 출력 파일 이름을 지정합니다.
      curl -o myfile.html http://example.com
      
  4. -d / –data [data]
    • HTTP POST 요청 시 데이터를 전송합니다.
      curl -d "param1=value1&param2=value2" http://example.com/resource
      
  5. -X / –request [command]
    • HTTP 요청 메서드를 지정합니다 (GET, POST, PUT, DELETE 등).
      curl -X POST http://example.com/resource
      
  6. -H / –header [header]
    • HTTP 요청에 헤더를 추가합니다.
      curl -H "Content-Type: application/json" http://example.com/resource
      
  7. -u / –user [user]
    • 서버 인증이 필요한 경우 사용자 이름과 비밀번호를 제공합니다.
      curl -u username:password http://example.com
      

고급옵션

  1. -F / –form [name=content]
    • HTTP POST 요청으로 파일 업로드를 처리합니다 (멀티파트/폼 데이터).
      curl -F "file=@/path/to/file" http://example.com/upload
      
  2. -I / –head
    • 서버의 응답 헤더만 요청합니다.
      curl -I http://example.com
      
  3. -k / –insecure
    • SSL 인증서를 검증하지 않습니다 (비추천, 보안 취약성).
      curl -k https://example.com
      
  4. -s / –silent
    • 진행 상태나 오류 메시지를 출력하지 않습니다.
      curl -s http://example.com
      
  5. -v / –verbose
    • 상세한 정보를 출력합니다 (디버깅에 유용).
      curl -v http://example.com
      
  6. –limit-rate [speed]
    • 다운로드 속도를 제한합니다.
      curl --limit-rate 100k http://example.com/file.zip
      
  7. -C / –continue-at [offset]
    • 다운로드를 중단된 위치에서 다시 시작합니다.
      curl -C - http://example.com/file.zip
      
  8. -e / –referer [URL]
    • 요청에 참조 URL을 포함합니다.
      curl -e http://referrer.com http://example.com
      
  9. -A / –user-agent [string]
    • 사용자 에이전트를 설정합니다.
      curl -A "Mozilla/5.0" http://example.com
      
  10. -b / –cookie [data]
    • 쿠키 데이터를 전송합니다.
        curl -b "name=value" http://example.com
      
  11. -c / –cookie-jar [file]
    • 쿠키 데이터를 파일에 저장합니다.
        curl -c cookies.txt http://example.com
      

예제

  • GET 요청:
    curl http://example.com
    
  • POST 요청:
    curl -X POST -d "param1=value1&param2=value2" http://example.com/resource
    
  • 파일 다운로드:
    curl -O https://example.com/file.zip
    
  • JSON 데이터 전송:
    curl -X POST -H "Content-Type: application/json" -d '{"key1":"value1", "key2":"value2"}' http://example.com/resource
    

카테고리:

업데이트:

댓글남기기