系统运维-21-4-http工具

curl命令
    基于URL语法在命令行方式下工作的文件传输工具
    支持FTP FTPS HTTP HTTPS GOPHER TELNET DICT FILE 及LDAP等协议
    支持HTTPS认证
    支持HTTP的POST PUT等方法
    支持FTP上传
    支持KERBEROS认证
    支持HTTP上传
    支持代理服务器,COOKIES,用户名/密码认证,下载文件断点续传,上载文件断点续传,HTTP代理服务器管道(PROXY TUNNELING)
    支持IPV6,SOCKS5代理服务器,通过HTTP代理服务器上传文件到FTP服务器等

curl常用选项
    -A/--user-agent 设置用户代理发送给服务器
    -basic 使用HTTP基本认证
    --tcp-nodelay 使用TCP_NODELAY选项
    -e/--referer 来源网址
    --cacert CA证书 SSL
    --compressed 要求返回是压缩的格式
    -H/--header 自定义头部信息传递给服务器
    -I/--head 只显示响应报文首部信息
    --limit-rate 设置传输速度
    -u/--user 设置服务器的用户和密码
    -0/--http1.0 使用HTTP1.0

curl实例:
    [root@lab2 ~]# curl 172.20.0.132
    page web1
    [root@lab1 ~]# tail /var/log/httpd/web1_access_log
    172.20.0.128 - - [05/May/2019:07:50:54 -0400] "GET / HTTP/1.1" 200 10 "-" "curl/7.29.0"
    [root@lab2 ~]# curl -A 'IE11' 172.20.0.132
    page web1
    [root@lab1 ~]# tail -1 /var/log/httpd/web1_access_log
    172.20.0.128 - - [05/May/2019:07:52:44 -0400] "GET / HTTP/1.1" 200 10 "-" "IE11"
    [root@lab2 ~]# curl -e "http://www.google.com.hk/search" http://172.20.0.132/index.html
    page web1
    [root@lab1 ~]# tail -1 /var/log/httpd/web1_access_log
    172.20.0.128 - - [05/May/2019:08:01:53 -0400] "GET /index.html HTTP/1.1" 200 10 "http://www.google.com.hk/search" "curl/7.29.0"
    [root@lab2 ~]# curl -I http://172.20.0.132/index.html
    HTTP/1.1 200 OK
    Date: Sun, 05 May 2019 12:05:32 GMT
    Server: Apache/2.4.6 (CentOS)
    Last-Modified: Sat, 04 May 2019 15:38:22 GMT
    ETag: "a-58811a846a6dd"
    Accept-Ranges: bytes
    Content-Length: 10
    Content-Type: text/html; charset=UTF-8


elinks工具
    [root@lab2 ~]# elinks http://172.20.0.132/index.html
    [root@lab2 ~]# elinks -dump http://172.20.0.132/index.html
       page web1

 

使用mod_deflate模块压缩页面优化传输速度
    适用场景
        1)节约带宽,额外消耗CPU,同时可能有些较老浏览器不支持
        2)压缩适用压缩的资源,例如文本文件

mod_deflate压缩实例:
    [root@lab1 ~]# wc -l /var/log/messages
    409 /var/log/messages
    [root@lab1 ~]# cp /var/log/messages /vhosts/web1/htdocs/test.html
    [root@lab1 ~]# chmod 644 /vhosts/web1/htdocs/test.html
    [root@lab1 ~]# vim /etc/httpd/conf/httpd.conf
    [root@lab1 ~]# tail -19 /etc/httpd/conf/httpd.conf
    SetOutputFilter DEFLATE
    # mod_deflate configuration
    # Restrict compression to these MIME types
    AddOu

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值