如何在我的 HTTP 请求中使用带有身份验证的代理? [英] How to use proxies with authentication in my HTTP requests?

查看:24
本文介绍了如何在我的 HTTP 请求中使用带有身份验证的代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个代理 IP 地址(也需要用户名和密码).当我尝试使用它们访问网页时,我收到需要代理身份验证".

I have a proxy IP Address (that also require a username and password). When i try using them to visit webpages, i get "Proxy Authentication Required".

我发现了 2016 年的其他 Stackoverflow 帖子,以及已关闭的 Github 问题,但它们没有提供任何有用的信息:

I'm found this other Stackoverflow post from 2016, and this Github Issue that was closed, but they don't provide anything useful:

有什么建议吗?

看到这个帖子:为 HTTP 客户端设置代理

有点接近.但是,对于某些网址,我可以使用我的代理获得成功响应,但对于某些网址,我会收到需要代理授权".

It's kinda close. However, for some urls I'm able to get a successful response using my proxy, but for certain urls, I get a "Proxy Authorization Required".

推荐答案

如果您正在关注此授权代理教程,您需要做的额外步骤是在传输中设置 HEADER.

If you're following this authorized proxy tutorial, the additional step you would have to do is to set up the HEADER in the transport.

auth := "username:password"
basicAuth := "Basic " + base64.StdEncoding.EncodeToString([]byte(auth))
transport.ProxyConnectHeader = http.Header{}
transport.ProxyConnectHeader.Add("Proxy-Authorization", basicAuth)

这篇关于如何在我的 HTTP 请求中使用带有身份验证的代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆