Linux curl命令

简介

curl命令用于向URL传输数据,常用于http接口测试。

支持的协议:DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP

使用方式举例

$ curl  "http://www.baidu.com" # 打印出了整个响应报文
$ curl -i "http://www.baidu.com" # 打印除了报文还有响应头信息
$ curl -I "http://www.baidu.com" # 仅返回http头信息
$ curl -v "http://www.baidu.com" # 打印更多的调试信息
$ curl -vI "http://www.baidu.com"
* Rebuilt URL to: http://www.baidu.com/
*   Trying 103.235.46.39...
* TCP_NODELAY set
* Connected to www.baidu.com (103.235.46.39) port 80 (#0)
> HEAD / HTTP/1.1
> Host: www.baidu.com
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Accept-Ranges: bytes
Accept-Ranges: bytes
< Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
< Connection: keep-alive
Connection: keep-alive
< Content-Length: 277
Content-Length: 277
< Content-Type: text/html
Content-Type: text/html
< Date: Wed, 20 Oct 2021 14:53:46 GMT
Date: Wed, 20 Oct 2021 14:53:46 GMT
< Etag: "575e1f6f-115"
Etag: "575e1f6f-115"
< Last-Modified: Mon, 13 Jun 2016 02:50:23 GMT
Last-Modified: Mon, 13 Jun 2016 02:50:23 GMT
< Pragma: no-cache
Pragma: no-cache
< Server: bfe/1.0.8.18
Server: bfe/1.0.8.18

< 
* Connection #0 to host www.baidu.com left intact

使用POST方法:

-d, --data HTTP POST data
–data-ascii HTTP POST ASCII data
–data-binary HTTP POST binary data
–data-raw HTTP POST data, ‘@’ allowed
–data-urlencode HTTP POST data url encoded
–delegation GSS-API delegation permission
–digest Use HTTP Digest Authentication

$ curl -d 'abc=def' "http://www.baidu.com" # 使⽤post⽅法提交http请求
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值