curl.cheat 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. % curl, http
  2. # GET 请求示例:
  3. curl <url>
  4. # POST 请求示例:curl -X POST -d "username=user&password=pass" http://example.com/login
  5. curl -X POST -d "<key_value>" <url>
  6. # JSON 请求示例:curl -H "Content-Type: application/json" -d '{"name": "John", "age": 30}' http://example.com/data
  7. curl -H "Content-Type: application/json" -d '<key_value>' <url>
  8. # 文件上传示例:
  9. curl -F "file=@<file_path>" <url>
  10. # 下载shell并立即执行
  11. curl -sSL <url> | sh
  12. # 下载文件
  13. curl -O <url>
  14. # send a get http request
  15. curl <url>
  16. # send a http request
  17. curl -X <method> <url>
  18. # send a http request and write the output to a file
  19. curl -X <method> <url> -o <filename>
  20. # send a get http request and follow redirects
  21. curl -L <url>
  22. # send a get http request exit with a non-zero status code on failure
  23. curl --fail <url>
  24. # send an authenticated http request
  25. curl -u <username>:<password> -X <method> <url>
  26. # send a http request with a json body
  27. curl -X <method> <url> -H 'Content-Type: application/json' -d '<json>'
  28. # send a http request with a form body
  29. curl <url> -d <bodykey>=<bodyvalue>
  30. # send a http request and see the request as well as the response
  31. curl -v <url>
  32. # send a http request with a body from a file
  33. curl -X <method> <url> --data-binary "@<file>"
  34. # send a http request with a custom header
  35. curl -X <method> <url> -H "<headername>: <headervalue>"
  36. $ file: ls
  37. $ method: echo -e 'GET\nPOST\nPUT\nDELETE\nPATCH'