安装包含本地参考和全部已发布模式的完整包。
install curlcurl当你需要知道远程端点从服务器侧实际如何响应时使用
curl <url|host|me> [options]curl me使用当前主机
curl example.com发送 GET 请求并显示状态和正文
curl example.com -I仅显示最终响应头
curl example.com -s [file]保存响应;省略名称时使用 URL 文件名
curl example.com -X POST -d "a=1"发送请求正文
-X <method>设置 HTTP 方法
-d <data>设置请求正文;默认 POST
-H "Name: value"添加请求头;可重复指定
-u <user>通过隐藏密码输入使用 HTTP Basic 身份验证
-c '{"name":"value"}'从 JSON 对象发送 cookie
-s [file] | -o <file>将响应保存到主机
-a追加而非替换;需要 -s 或 -o
-i包含最终响应头
-I仅显示最终响应头
-j以结构化 JSON 显示响应
-edit @edit在文本编辑器中打开响应正文
-code @code在代码编辑器中打开响应正文
-t [seconds]使用 5 秒或 1 到 300 秒的自定义超时
-T使用 300 秒超时
-4 | -6在
-r不跟随重定向
-k允许不安全的 TLS 证书
先用
-u <user> 单独请求密码,但命令中 -d 的数据或 cookie 可能留在历史记录。默认验证 TLS 证书并最多跟随五次重定向;-k 禁用证书验证,-r 禁用重定向。没有 PHP -4/-6 必须使用
缺少 PHP
可直接在页面中运行预先准备的示例。结果已预先生成并在浏览器中显示;服务器不会执行任何终端命令。
安装当前兼容版本。完整功能请选择 Base,精简包请选择 Minimum;已安装模块的更新请使用 upgrade。
Base 与 Minimum 是同一当前模块版本的两个包。
安装包含本地参考和全部已发布模式的完整包。
install curl安装精简包。该包不包含本地参考;
install curl -m安装这个确切的已发布版本。
install curl -v 1.2.5让 upgrade 检查兼容性,仅在需要时替换已安装块。
upgrade curl删除扩展块,不影响核心和其他模块。
install curl -u示例可复制,但网站不会执行。请先检查路径、权限和破坏性选项。
curl https://example.com网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
<!doctype html>
<html>…</html>curl me网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
<!doctype html>
<html>…</html>curl https://example.com -I网络教学示例 — 不发送真实请求
HTTP/2 200
content-type: text/html; charset=UTF-8
cache-control: max-age=86000curl https://example.com -i网络教学示例 — 不发送真实请求
HTTP/2 200
content-type: text/html; charset=UTF-8
<!doctype html>
<html>…</html>curl https://example.com -j网络教学示例 — 不发送真实请求
{
"status": 200,
"url": "https://example.com/",
"headers": [
"HTTP/2 200",
"content-type: text/html; charset=UTF-8"
],
"body": "<html>…</html>"
}curl https://example.com -X POST -d "name=lil"网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Example response to a POST request; the server may reject POST or return another status.curl https://example.com -d "name=lil"网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Example response to a POST request; the server may reject POST or return another status.curl https://example.com -H "Accept: application/json"网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Request contains custom headers; the remote reply depends on the endpoint.curl https://example.com -H "Accept: application/json" -H "X-Demo: 1"网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Request contains custom headers; the remote reply depends on the endpoint.curl https://example.com -c '{"theme":"dark"}'网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Request includes Cookie: theme=dark; the server decides how to respond.curl https://example.com -u demo网络教学示例 — 不发送真实请求
A separate secret-password prompt appears before the request is sent.curl https://example.com -s网络教学示例 — 不发送真实请求
sandbox/
index.html
The response body is saved on the hosting account.curl https://example.com -s tmp/example.html网络教学示例 — 不发送真实请求
sandbox/tmp/
example.html
The response body is saved on the hosting account.curl https://example.com -o tmp/example.html网络教学示例 — 不发送真实请求
sandbox/tmp/
example.html
The response body is saved on the hosting account.curl https://example.com -o tmp/example.html -a网络教学示例 — 不发送真实请求
sandbox/tmp/
example.html
The body is appended to the existing file.curl https://example.com -t网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Timeout option changes the maximum wait, not the response format.curl https://example.com -t 2网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Timeout option changes the maximum wait, not the response format.curl https://example.com -T网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Timeout option changes the maximum wait, not the response format.curl https://example.com -4网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Requested IP family IPv4 (requires PHP cURL).curl https://example.com -6网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Requested IP family IPv6 (requires PHP cURL).curl https://example.com -r网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Redirect following disabled; response status depends on endpoint.curl https://example.com -k网络教学示例 — 不发送真实请求
HTTP: 200
URL: https://example.com/
Certificate verification disabled for this diagnostic request.curl https://example.com -edit网络教学示例 — 不发送真实请求
The installed text editor opens the response in a protected temporary file.curl https://example.com -code网络教学示例 — 不发送真实请求
The installed code editor opens the response in a protected temporary file.curl https://example.com -j -code网络教学示例 — 不发送真实请求
The installed code editor opens the response in a protected temporary file as formatted JSON.curl https://example.com -edit -s tmp/example.html网络教学示例 — 不发送真实请求
Editor mode cannot be combined with -s or -ocurl https://example.com -a网络教学示例 — 不发送真实请求
Append requires an output filecurl ftp://example.com网络教学示例 — 不发送真实请求
Invalid URLcurl https://example.com -4 -6网络教学示例 — 不发送真实请求
Choose either IPv4 or IPv6curl https://example.com -X 9bad网络教学示例 — 不发送真实请求
Invalid HTTP methodcurl https://example.com -H "broken"网络教学示例 — 不发送真实请求
Invalid headercurl https://example.com -c not-json网络教学示例 — 不发送真实请求
Invalid cookie JSONcurl https://example.com -t 301网络教学示例 — 不发送真实请求
Invalid timeoutcurl https://example.com -o网络教学示例 — 不发送真实请求
Output file requiredcurl https://example.com -edit -code网络教学示例 — 不发送真实请求
Choose one editor