Skip to content

Call https website through proxy will cause error #1745

Closed
@tangyouze

Description

Long story short

Call https website through http proxy will cause an internal error, however the result can be get.

This happens in version 2.0.0, aiohttp 1.3.5 works fine

Expected behaviour

No Warning is given

Actual behaviour

Some error message is printed out

Traceback (most recent call last):
  File "/Users/tyz/.pyenv/versions/3.5.0/lib/python3.5/site-packages/aiohttp/streams.py", line 158, in feed_eof
    cb()
  File "/Users/tyz/.pyenv/versions/3.5.0/lib/python3.5/site-packages/aiohttp/client_reqrep.py", line 567, in _response_eof
    if self._connection.protocol.upgraded:
AttributeError: 'NoneType' object has no attribute 'upgraded'

Steps to reproduce

service.qbtrade.org:4444 is blocked by firewall, and need to be replaced by some other proxy to run the example, however I cannot find some free proxy online

script.py

import asyncio
import aiohttp

import sys

print(sys.version)
print(aiohttp.__version__)


async def r():
    async with aiohttp.ClientSession() as t:
        # proxy needs to be replaced
        t = await t.get('https://httpbin.org/get', proxy='http://service.qbtrade.org:4444')
        print(await t.text())


asyncio.get_event_loop().run_until_complete(r())

result:

/Users/tyz/.pyenv/versions/3.5.0/bin/python /Users/tyz/Dropbox/qb/qb_playground/aiohttp-error.py
3.5.0 (default, Mar 11 2017, 09:13:49) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
2.0.2
Exception in eof callback
Traceback (most recent call last):
  File "/Users/tyz/.pyenv/versions/3.5.0/lib/python3.5/site-packages/aiohttp/streams.py", line 158, in feed_eof
    cb()
  File "/Users/tyz/.pyenv/versions/3.5.0/lib/python3.5/site-packages/aiohttp/client_reqrep.py", line 567, in _response_eof
    if self._connection.protocol.upgraded:
AttributeError: 'NoneType' object has no attribute 'upgraded'
{
  "args": {}, 
  "headers": {
    "Accept": "*/*", 
    "Accept-Encoding": "gzip, deflate", 
    "Connection": "close", 
    "Host": "httpbin.org", 
    "User-Agent": "Python/3.5 aiohttp/2.0.2"
  }, 
  "origin": "47.90.20.145", 
  "url": "https://httpbin.org/get"
}


Process finished with exit code 0

Your environment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions