aiohttp是否支持HTTPS代理 [英] Does aiohttp support HTTPS proxies

查看:208
本文介绍了aiohttp是否支持HTTPS代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试通过HTTPS代理发出请求时-

When I try to make a request through an HTTPS proxy-

async with session.get(
    url
    headers={"k": v},
    proxy='https://my-proxy.com:1234',
) as response:
    resp_json = await response.json()

我的请求失败,但出现以下异常:

My request fails with the following exception:

raise ValueError("Only http proxies are supported")

这对应于源代码.

但是,文档表示HTTPS代理是支持.

However, the docs say that HTTPS proxies are supported.

这是文档中的疏忽吗?还是我做错了?

Is this an oversight in the docs or am I doing this incorrectly?

推荐答案

我打开了回购中的问题,安德鲁·斯维特洛夫(Andrew Svetlov)十分友好,可以澄清. aiohttp 支持纯HTTP客户端和可以通过HTTP CONNECT升级到HTTPS的HTTP客户端.我发出了拉动请求以更新文档.

I opened an issue in the repo and Andrew Svetlov was kind enough to clarify. aiohttp supports plain HTTP clients and HTTP clients that can be upgraded to HTTPS via HTTP CONNECT. I made a pull request to update the docs.

这篇关于aiohttp是否支持HTTPS代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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