CLI 환경 CURL 사용 예제 모음 (GET/POST/DELETE/PUT/HEAD)
- 공유 링크 만들기
- X
- 이메일
- 기타 앱
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) ```
댓글
댓글 쓰기