栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Linux curl命令

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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请求
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/335140.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号