如何轻松测试HTTP返回码,比如301重定向?
例如,如果我想要“查看发生了什么”,可以使用telnet执行以下操作:
... $ telnet nytimes.com 80
Trying 199.239.136.200...
Connected to nytimes.com.
Escape character is '^]'.
GET / HTTP/1.0
(按下回车键)
(按下回车键)
HTTP/1.1 200 OK
Server: Sun-ONE-Web-Server/6.1
Date: Mon, 14 Jun 2010 12:18:04 GMT
Content-type: text/html
Set-cookie: RMID=007af83f42dd4c161dfcce7d; expires=Tuesday, 14-Jun-2011 12:18:04 GMT; path=/; domain=.nytimes.com
Set-cookie: adxcs=-; path=/; domain=.nytimes.com
Set-cookie: adxcs=-; path=/; domain=.nytimes.com
Set-cookie: adxcs=-; path=/; domain=.nytimes.com
Expires: Thu, 01 Dec 1994 16:00:00 GMT
Cache-control: no-cache
Pragma: no-cache
Connection: close
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
...
有一种简单的方法可以获得相当多的信息。
但是现在我想测试一下301重定向确实是一个301重定向。
我该怎么做呢?
基本上,我想知道如何获取到301而不是获取到HTTP/1.1 200 OK。
我知道我可以在浏览器中输入URL的名称并“查看”重定向,但我想知道哪些工具可以用于真正地“查看”301重定向。
顺便说一句,我尝试使用telnet进行测试,但是当我输入www.example.org(我将其重定向到没有www的example.org)时,我只能看到“200 OK”,我无法看到301。