CLI 환경 CURL 사용 예제 모음 (GET/POST/DELETE/PUT/HEAD)

HEAD 요청

``` // 요청 예시 curl -I https://www.example.com

-- // 서버가 받았을 때 전문 HEAD / HTTP/1.1 Host: www.example.com ```

DELETE 요청

``` // 요청 예시 curl -X DELETE https://www.example.com/resource

-- // 서버가 받았을 때 전문 DELETE /resource HTTP/1.1 Host: www.example.com ```

POST 요청 ( plain-text body )

``` // 요청 예시 curl -X POST -d "data=Hello, World!" https://www.example.com/resource -- // 서버가 받았을 때 전문 POST /resource HTTP/1.1 Host: www.example.com Content-Length: 18 Content-Type: application/x-www-form-urlencoded

data=Hello, World! ```

POST JSON 요청 ( plain-text body )

``` // 요청 예시 curl -X POST -H "Content-Type: application/json" -d '{"key": "value"}' https://www.example.com/resource -- // 서버가 받았을 때 전문 POST /resource HTTP/1.1 Host: www.example.com Content-Type: application/json Content-Length: 15

{"key": "value"} ```

POST 파일 업로드

``` // 요청 예시 curl -X POST -F "file=@path/to/file" https://www.example.com/upload -- // 서버가 받았을 때 전문 POST /upload HTTP/1.1 Host: www.example.com Content-Length: 194 Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="file"; filename="example.txt" Content-Type: text/plain

(binary) ------WebKitFormBoundary7MA4YWxkTrZu0gW-- ```

PUT 요청

``` // 요청 예시 curl -X PUT -d "data=New Data" https://www.example.com/resource -- // 서버가 받았을 때 전문 PUT /resource HTTP/1.1 Host: www.example.com Content-Length: 9

data=New Data ```

PUT 파일 업로드

``` // 요청 예시 curl --upload-file path/to/file https://www.example.com/upload -- // 서버가 받았을 때 전문 PUT /upload HTTP/1.1 Host: www.example.com Content-Length: 1234 Content-Type: application/octet-stream

(binary) ```

댓글

이 블로그의 인기 게시물

[로스트아크] 제작 효율 최적화 위한 영지 세팅

[로스트아크] 로스트아크 생활 도구 옵션

한국 핵무장 논의와 방위산업 관련주: 핵무기 개발 과정과 유망 종목 분석