关于 HTTP 通讯的疑问
关于 HTTP 通信的疑问
以上是我发送的发送的包,但收到的回复是
HTTP/1.1 301 Moved Permanently Server: nginx/0.5.23 Date: Wed, 07 Sep 2011 02:52:05 GMT Content-Type: text/html Content-Length: 185 Connection: keep-alive Location: http://bjdnserror6.wo.com.cn:8080?HOST=www.baidu.com&R=/&
301 Moved Permanently
我包头哪里写错了?
------解决方案--------------------
用抓包工具抓浏览器访问的包,然后跟你发送的对比,diff区别
------解决方案--------------------
URL 重定向
------解决方案--------------------
HTTP 301
Persistence · Compression · HTTPS
Request methods
OPTIONS · GET · HEAD · POST · PUT · DELETE · TRACE · CONNECT
Header fields
Cookie · ETag · Location · Referer
X-Forwarded-For
Status codes
301 Moved permanently
302 Found
303 See Other
403 Forbidden
404 Not Found
The HTTP response status code 301 Moved Permanently is used for permanent redirection. This status code should be used with the location header. RFC 2616 states that:
If a client has link-editing capabilities, it should update all references to the Request URI.
The response is cachable.
Unless the request method was HEAD, the entity should contain a small hypertext note with a hyperlink to the new URI(s).
If the 301 status code is received in response to a request of any type other than GET or HEAD, the client must ask the user before redirecting.
------解决方案--------------------
数据包是正确的。
这个应该是正常的返回了。
------解决方案--------------------
重定向了,收到重定向的返回时,再连一次,去打开重定向的地址好了。
------解决方案--------------------
3XX,状态码,表明资源被迁移到其它位置,需要请求者按指示,向新的位置发请求
位置信息,解析响应头的Location:域获取
- C/C++ code
//Http header string strHeader; strHeader = "GET / HTTP/1.1\r\n"; strHeader += "Accept:*/*\r\n"; strHeader += "Accept-Language: zh-cn\r\n"; strHeader += "Cache-Control: no-cache\r\n"; strHeader += "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322; InfoPath.2)\r\n"; strHeader += "Host: www.baidu.com:80\r\n"; strHeader += "Connection: Keep-Alive\r\n"; strHeader += "\r\n";
以上是我发送的发送的包,但收到的回复是
HTTP/1.1 301 Moved Permanently Server: nginx/0.5.23 Date: Wed, 07 Sep 2011 02:52:05 GMT Content-Type: text/html Content-Length: 185 Connection: keep-alive Location: http://bjdnserror6.wo.com.cn:8080?HOST=www.baidu.com&R=/&
301 Moved Permanently
我包头哪里写错了?
------解决方案--------------------
用抓包工具抓浏览器访问的包,然后跟你发送的对比,diff区别
------解决方案--------------------
URL 重定向
------解决方案--------------------
HTTP 301
Persistence · Compression · HTTPS
Request methods
OPTIONS · GET · HEAD · POST · PUT · DELETE · TRACE · CONNECT
Header fields
Cookie · ETag · Location · Referer
X-Forwarded-For
Status codes
301 Moved permanently
302 Found
303 See Other
403 Forbidden
404 Not Found
The HTTP response status code 301 Moved Permanently is used for permanent redirection. This status code should be used with the location header. RFC 2616 states that:
If a client has link-editing capabilities, it should update all references to the Request URI.
The response is cachable.
Unless the request method was HEAD, the entity should contain a small hypertext note with a hyperlink to the new URI(s).
If the 301 status code is received in response to a request of any type other than GET or HEAD, the client must ask the user before redirecting.
------解决方案--------------------
数据包是正确的。
这个应该是正常的返回了。
------解决方案--------------------
重定向了,收到重定向的返回时,再连一次,去打开重定向的地址好了。
------解决方案--------------------
3XX,状态码,表明资源被迁移到其它位置,需要请求者按指示,向新的位置发请求
位置信息,解析响应头的Location:域获取