Can';t通过golang http.get()获取内容,改为500错误。为什么?

Can';t通过golang http.get()获取内容,改为500错误。为什么?,http,get,go,Http,Get,Go,我无法获取站点的内容,它返回500错误。但如果我切换到www.google.com.hk或其他网站,也没关系。为什么? 下面是代码 package main import ( "fmt" "io/ioutil" "log" "net/http" ) func main() { resp, err := http.Get("http://www.eqsn.gov.cn") //the browsers,IE\firefox access it is ok

我无法获取站点的内容,它返回500错误。但如果我切换到www.google.com.hk或其他网站,也没关系。为什么?

下面是代码

package main

import (
    "fmt"
    "io/ioutil"
    "log"
    "net/http"
)

func main() {
    resp, err := http.Get("http://www.eqsn.gov.cn") //the browsers,IE\firefox access it is ok.
    // resp, err := http.Get("http://www.google.com.hk")  //It's ok.

    if err != nil {
        log.Fatalf("http.Get => %v", err.Error())
    }
    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Printf("\n%v\n\n", string(body))
}

如果执行
http.Get()
返回错误500(内部服务器错误),则该错误很可能来自服务器。事实上,让我们手动尝试。选项
-D-
转储标题

$ curl -D- http://www.eqsn.gov.cnHTTP/1.0 500 Internal Server Error
Date: Mon, 17 Jun 2013 02:01:11 GMT
Content-Type: text/html; charset=iso-8859-1
Content-Length: 538
X-Powered-By: 
X-AspNet-Version: 
MicrosoftOfficeWebServer: 
Server: 
X-Cache: MISS from CNC-JSWX-254-131.fastcdn.com
X-Cache: MISS from CT-ZJNB-152-196.fastcdn.com
Connection: close

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 [no address given] and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>
$curl-D-http://www.eqsn.gov.cnHTTP/1.0 500内部服务器错误
日期:2013年6月17日星期一02:01:11 GMT
内容类型:text/html;字符集=iso-8859-1
内容长度:538
X供电:
X-AspNet-Version:
MicrosoftOfficeWebServer:
服务器:
X-Cache:CNC-JSWX-254-131.fastcdn.com中的未命中
X-Cache:CT-ZJNB-152-196.fastcdn.com未命中
连接:关闭
500内部服务器错误
内部服务器错误
服务器遇到内部错误或错误
配置错误,无法完成
你的要求

请与服务器管理员联系, [没有给出地址]并通知他们错误发生的时间, 你可能做的任何事都可能 导致错误的原因

有关此错误的详细信息,请参阅 在服务器错误日志中


如您所见,服务器给您一个错误500。围棋很好;它给出服务器发送的错误500。如果您还有其他问题,请随时提问。

如果执行http.Get()返回错误500(内部服务器错误),则此错误很可能来自服务器。事实上,让我们手动尝试。选项
-D-
转储标题

$ curl -D- http://www.eqsn.gov.cnHTTP/1.0 500 Internal Server Error
Date: Mon, 17 Jun 2013 02:01:11 GMT
Content-Type: text/html; charset=iso-8859-1
Content-Length: 538
X-Powered-By: 
X-AspNet-Version: 
MicrosoftOfficeWebServer: 
Server: 
X-Cache: MISS from CNC-JSWX-254-131.fastcdn.com
X-Cache: MISS from CT-ZJNB-152-196.fastcdn.com
Connection: close

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
 [no address given] and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>
$curl-D-http://www.eqsn.gov.cnHTTP/1.0 500内部服务器错误
日期:2013年6月17日星期一02:01:11 GMT
内容类型:text/html;字符集=iso-8859-1
内容长度:538
X供电:
X-AspNet-Version:
MicrosoftOfficeWebServer:
服务器:
X-Cache:CNC-JSWX-254-131.fastcdn.com中的未命中
X-Cache:CT-ZJNB-152-196.fastcdn.com未命中
连接:关闭
500内部服务器错误
内部服务器错误
服务器遇到内部错误或错误
配置错误,无法完成
你的要求

请与服务器管理员联系, [没有给出地址]并通知他们错误发生的时间, 你可能做的任何事都可能 导致错误的原因

有关此错误的详细信息,请参阅 在服务器错误日志中


如您所见,服务器给您一个错误500。围棋很好;它给出服务器发送的错误500。如果您还有其他问题,请随时提问。

这似乎与
Go
无关。您正在确认收到响应,因此
Go
工作正常。如果您实际设置的请求头与浏览器设置的请求头相同,我可能会认为这是一个问题。您请求的站点出现了问题,
curlhttp://www.eqsn.gov.cn/
也返回500。这很有趣。所说的URL在我的浏览器中加载良好。它可能会分析用户代理。这似乎与
Go
无关。您正在确认收到响应,因此
Go
工作正常。如果您实际设置的请求头与浏览器设置的请求头相同,我可能会认为这是一个问题。您请求的站点出现了问题,
curlhttp://www.eqsn.gov.cn/
也返回500。这很有趣。所说的URL在我的浏览器中加载良好。它可能会分析用户代理。