curl/wget 测试http请求的响应头信息
1. wget –debug
wget可以使用debug信息来查看信息头,如下:
[root@localhost ~]# wget --debug http://192.168.1.101:8080/UFE/service/test
DEBUG output created by Wget 1.12 on linux-gnu. --2015-03-31 19:01:03-- http://192.168.1.101:8080/UFE/service/test
正在连接 192.168.1.101:8080... 已连接。
Created socket 3.
Releasing 0x000000000087cca0 (new refcount 0).
Deleting unused 0x000000000087cca0. ---request begin---
GET /UFE/service/test HTTP/1.0
User-Agent: Wget/1.12 (linux-gnu)
Accept: */ *
Host: 192.168.1.101:8080
Connection: Keep-Alive ---request end---
已发出 HTTP 请求,正在等待回应...
---response begin---
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: x-requested-with
Content-Type: text/plain;charset=ISO-8859-1
Content-Length: 14
Date: Tue, 31 Mar 2015 11:13:47 GMT
Connection: keep-alive ---response end---
200 OK
Registered socket 3 for persistent reuse.
长度:14 [text/plain]
正在保存至: “test.1” 100%[======================================>] 14 --.-K/s in 0s 2015-03-31 19:01:03 (2.03 MB/s) - 已保存 “test.1” [14/14])
2. wget -save-headers
以使用-S、–save-headers选项,不过此时只能查看响应头部信息,注意,debug和save-headers都会输出到文件。
3. wget --spider
判断一个文件或者页面是否存在,可以使用一下命令:
[root@localhost ~]# wget --spider -nv http://ip/bugfree/index.php
2015-03-31 19:12:42 URL: http://ip/bugfree/index.php/site/login 200 OK
4. curl -v
可以查看url的文件头信息,如下:
[root@localhost ~]# curl -v http://192.168.1.101:8080/UFE/service/test
* About to connect() to 192.168.1.101 port 8080 (#0)
* Trying 192.168.1.101... connected
* Connected to 192.168.1.101 (192.168.1.101) port 8080 (#0)
> GET /UFE/service/test HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.8 libidn/1.18 libssh2/1.4.2
> Host: 192.168.1.101:8080
> Accept: */ *
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE
< Access-Control-Max-Age: 3600
< Access-Control-Allow-Headers: x-requested-with
< Content-Type: text/plain;charset=ISO-8859-1
< Content-Length: 14
< Date: Tue, 31 Mar 2015 11:28:11 GMT
<
* Connection #0 to host 192.168.1.101 left intact
* Closing connection #0
5. curl -I
利用curl的-I(大写i)--head 选项仅查看响应头部信息:
[root@localhost ~]# curl -I http://192.168.1.101:8080/UFE/service/test
HTTP/1.1 405 Method Not Allowed
Server: Apache-Coyote/1.1
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: x-requested-with
Allow: GET
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1047
Date: Tue, 31 Mar 2015 11:31:42 GMT
6. 获取url的状态码
[root@localhost ~]# curl -o /dev/null -s -w %{http_code} http://192.168.1.101:8080/UFE/service/test
200
curl/wget 测试http请求的响应头信息的更多相关文章
- wget/curl查看请求响应头信息
wget / curl 是两个比较方便的测试http功能的命令行工具,大多数情况下,测试http功能主要是查看请求响应 头信息 ,而给这两个工具加上适当的命令行参数即可轻易做到,其实查man手册就能找 ...
- HTTP状态码、请求方法、响应头信息
HTTP状态码 当浏览者访问一个网页时,浏览者的浏览器会向网页所在服务器发出请求.当浏览器接收并显示网页前,此网页所在的服务器会返回一个包含HTTP状态码的信息头(server header)用以响应 ...
- php设置http请求头信息和响应头信息
php设置http请求头信息和响应头信息 设置请求服务器的头信息可以用fsockopen,curl组件,header函数只能用来设置客户端响应的头信息,不能设置服务器的头信息. 例子; 一.head ...
- 动手学servlet(三) 请求头和响应头信息
获取请求头信息 package servletdemo; import java.io.IOException; import java.util.Enumeration; import javax. ...
- HTTP协议请求头信息和响应头信息
阅读目录 http的请求部分 常用请头信息 常用响应头信息 http的请求部分 基本结构 请求行 GET /test/hello.html HTTP/1.1 消息头(并不是每一次请求都一样) 空行 ...
- curl get请求添加header头信息
function get($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_HTTPGET, true); curl_setopt($ch, CU ...
- 随笔——python截取http请求报文响应头
随笔——python截取http请求报文响应头 标签: pythonhttp响应头 2014-05-29 09:32 2114人阅读 评论(0) 收藏 举报 分类: 随笔(7) 版权声明:本文为博 ...
- HTTP请求响应头信息
HTTP请求响应头信息 请求:(request) 组成部分: 请求行 请求头 请求体 请求行:请求信息的第一行 格式:请求方式 访问的资源 协议/版本 例如:GET /day0801/1.html H ...
- HTTP 响应头信息
HTTP 响应头信息 HTTP请求头提供了关于请求,响应或者其他的发送实体的信息. 在本章节中我们将具体来介绍HTTP响应头信息.
随机推荐
- [转]DB2时间类函数
Src URL:http://www.cnblogs.com/wanghonghu/archive/2012/05/25/2518604.html 1.db2可以通过SYSIBM.SYSDUMMY1. ...
- location url 反向代理到来机的其它端口 gitlab
location /nexus { proxy_pass http://127.0.0.1:8081/nexus; } [root@GitMaven conf]# pwd /var/opt/gitla ...
- MVC - 16.MVC过滤器
filter n. 滤波器:[化工] 过滤器:筛选:滤光器 vt. 过滤:渗透:用过滤法除去 1.过滤器表 过滤器类型 接口 默认实现 描述 Action IActionFilte ...
- C#的匿名函数
using System; using System.Collections; using System.Collections.Generic; using System.IO; using Sys ...
- GMap.Net开发之技巧小结
1.在GMap地图上,如果要让添加的图标(Marker)有个高亮(highlight)的效果,可以在MouseOver到Marker的时候设置Marker外观效果. 如果要让图标有个报警闪烁的效果,可 ...
- Sql Server 基础知识
Sql Server 基础知识: http://blog.csdn.net/t6786780/article/details/4525652 Sql Server 语句大全: http://www.c ...
- view和activity的区别
activity相当于控制部分,view相当于显示部分.两者之间是多对多的关系,所有东西必须用view来显示. viewGroup继承自view,实现了ViewManager,ViewParent接 ...
- hibernate快速入门
第一步:下载Hibernate的开发包: http://sourceforge.net/projects/hibernate/files/hibernate3 第二步:Hibernate框架目录结构: ...
- Liferay 6.2 改造系列之二十:修改默认添加用户权限及用户是否拥有个人站点的配置
1.修改默认添加用户权限为User,而非Powers User: 在/portal-master/portal-impl/src/portal.properties文件中有如下配置: # # Inpu ...
- css用clearfix清除浮动
本文从http://www.studyofnet.com/news/196.html复制. 本文导读:写css 时总为浮动而烦恼,如果用了浮动,浮动的父层不会跟着浮动框的高度增加而增加,在Fire ...