向210.133.109.190发送Http请求,服务器可以返回内容,但是服务器返回的内容有问题,返回内容是Server端找不到相应的URL,可是这个URL通过浏览器是可以访问的呀,这个是日本的服务器,URL为:http://210.133.109.190/cgi-bin/msrs/getvics.cgi服务器返回内容是: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> 
<html> <head> 
<title>404 Not Found </title> 
</head> <body> 
<h1>Not Found </h1> 
<p>The requested URL /cgi-bin/msrs/getvics.cgi was not found on this server. </p> 
</body> </html> 
我发送HTTP请求的代码如下: strcat(m_cRequestHeader, "POST "); 
strcat(m_cRequestHeader, "/cgi-bin/msrs/getvics.cgi"); 
strcat(m_cRequestHeader, " HTTP/1.1"); 
strcat(m_cRequestHeader, "\r\n"); strcat(m_cRequestHeader, "Content-Type: text/xml; charset=UTF-8\r\n"); strcat(m_cRequestHeader, "Accept: */*\r\n"); strcat(m_cRequestHeader, "Connection: Keep-Alive\r\n"); strcat(m_cRequestHeader, "User-Agent: Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)\r\n"); strcat(m_cRequestHeader, "x-protocol-version:1.0\r\n"); //host name 
strcat(m_cRequestHeader, "Host:"); 
strcat(m_cRequestHeader, "210.133.109.190"); 
strcat(m_cRequestHeader,":"); 
strcat(m_cRequestHeader, "80"); 
strcat(m_cRequestHeader, "\r\n"); 以上的Http请求有什么问题吗? 请求达人解释错误原因呀!!

解决方案 »

  1.   

    使用WireShark抓包,看看你自己程序发的和浏览器包有什么不一样。
      

  2.   

    应该还是你发送的http请求不对,可以自己抓包看看
      

  3.   

    Host:域没有端口,端口是连接的参数
    头以空行结束"\r\n\r\n"
    POST 方式,必然有附加的实体数据,需要在头中指明Content-Length,Content-Type
    没有附加数据,会被某些服务器返回状态码:4xx(资源不存在的错误)
      

  4.   

    一个典型的POST请求:"POST /cgi-bin/msrs/getvics.cgi HTTP/1.1\r\n"
    "Accept: */*\r\n"
    "Host: 210.133.109.190\r\n"
    "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)\r\n"
    "Content-Length: 25\r\n"
    "Content-Type: application/x-www-form-urlencoded\r\n"
    "Connection: Close\r\n\r\n"
    "name1=value1&name2=value2"
      

  5.   


    怎么抓包呀?是把请求头打印出来吗?
    我的请求头如下:POST /cgi-bin/msrs/getvics.cgi HTTP/1.1
    Accept: */*
    Host:210.133.109.190:80
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
    Content-Type: text/plain; charset=UTF-8
    Connection: Keep-Alive
    x-protocol-version:1.0
    Content-Length: 95大家看看有什么问题吗?
      

  6.   


    服务器报的错误是这样的:
    <html><head>
    <title>404 Not Found</title>
    </head><body>
    <h1>Not Found</h1>
    <p>The requested URL /cgi-bin/msrs/getvics.cgi was not found on this server.</p>
    </body></html>我在浏览器中输入“http://210.133.109.190/cgi-bin/msrs/getvics.cgi”都没有问题呀,不信你们试试?这是郁闷
      

  7.   

    要用专门的抓包工具如netmon/ethereal去抓包,看看当你能正确返回时,IE发的报文是什么样子的
      

  8.   

    在IE输入上述地址,显示的是:
    GET /cgi-bin/rsrs/getvics.cgi HTTP/1.1同时,4楼也指出了,Host后面不应该有端口,你把":80"去掉