通过代理进行HTTP发布请求时需要代理授权

时间:2019-12-22 08:07:37

标签: go

我有proxyString 123.44.333.42:51244 并希望通过代理请求网址

proxyString := "123.44.333.42:51244"
proxyURL, err := url.Parse("http://"+proxyStr)
    if err != nil {
        panic(err)
    }
    ////adding the proxy settings to the Transport object
    transport := &http.Transport{
        Proxy: http.ProxyURL(proxyURL),
    }
client := &http.Client{
        Transport: transport,
        CheckRedirect: func(req *http.Request, via []*http.Request) error {
            return http.ErrUseLastResponse
        }}
        resp, contents := getContent(client, person.personHref)

得到错误Proxy Authentication Required

0 个答案:

没有答案