Without knowing the exact setup you're running, I can only guess, but this usually happens when the web server is filtering on request headers. You may need to add anAccept
and a User-Agent
header for the request to be allowed.
Try something like:
curl -i \
-H 'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
-H 'User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11' \
http://site-centos-64:8080/examples/abc1.jsp
If this works, you can set these headers in the Go code using the Header.Add() method.
package main
import "net/http"
import "fmt"
func main() {
client := &http.Client{
CheckRedirect: redirectPolicyFunc,
}
req, err := http.NewRequest("GET", "http://site-centos-64:8080/examples/abc1.jsp", nil)
req.Header.Add("Accept", `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8`)
req.Header.Add("User-Agent", `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11`)
resp, err := client.Do(req)
fmt.Println(resp,err)
}
The curl command above is modified from the answer to CURL HTTP/1.1 403 Forbidden Date .