You need to enable JavaScript to run this app.
导航

发送 HTTP 请求(curl)

最近更新时间2024.02.29 20:16:18

首次发布时间2024.02.29 20:16:18

您可以通过 curl 命令发送 HTTP 请求并获取响应结果。

curl

命令语法

./tosutil curl http(s)_url [-m=xxx] [-v] [-rb=xxx] [-fb=xxx] [-h=aaa:bbb#ccc:ddd] [-at=xxx] [-i=xxx] [-k=xxx] [-t=xxx]

参数说明

参数名

参数类型

描述

http(s)_url

String

发送 HTTP 请求的目标 URL。

-m

String

执行 curl 命令时的请求方法名。取值如下:

  • GET
  • PUT
  • POST
  • DELETE
  • HEAD

默认为 GET

-v

String

执行 curl 命令时,打印请求和响应的详细信息。

-rb

String

执行 curl 命令时的请求消息体,仅在请求方法为 PUTPOSTDELETE 时有效。

-fb

String

执行 curl 命令时使用本地文件作为请求消息体并指定该本地文件路径,仅在请求方法为 PUTPOSTDELETE 时有效。

-h=aaa:bbb#ccc:ddd

String

执行 curl 命令时的请求头域。

-at

String

执行 curl 命令时携带签名并指定签名的算法。取值如下:

  • tos

-i

String

签名算法的 Access Key ID。

-k

String

签名算法的 Secret Access Key

-t

String

签名算法的 STS Token。关于 STS 授权的具体步骤,请参见使用 STS 临时 AK/SK+Token 访问火山引擎 TOS

使用示例

  • 命令
./tosutil curl https://console.volcengine.com/home
  • 返回
* Status code: 302, Response Body: 

* The response is truncated, total length: 93, consumed length: 93
Redirecting to <a href="/auth/login?redirectURI=%2Fhome">/auth/login?redirectURI=%2Fhome</a>.