Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value Error Could not parse hostname from URL 'http://' #2241

Closed
steven2308 opened this issue Sep 4, 2017 · 2 comments
Closed

Value Error Could not parse hostname from URL 'http://' #2241

steven2308 opened this issue Sep 4, 2017 · 2 comments
Labels

Comments

@steven2308
Copy link

Long story short

When a request response is a redirect but location has an invalid url, a ValueError is raised.

Expected behaviour

raise a ClientError or some more specific error.

Actual behaviour

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/lib/python3.6/asyncio/base_events.py", line 449, in run_until_complete
    return future.result()
  File "/usr/lib/python3.6/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "<stdin>", line 4, in process
  File "/myenv/lib/python3.6/site-packages/aiohttp/client.py", line 604, in __aenter__
    self._resp = yield from self._coro
  File "/myenv/lib/python3.6/site-packages/aiohttp/client.py", line 228, in _request
    session=self, auto_decompress=self._auto_decompress)
  File "/myenv/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 97, in __init__
    self.update_host(url)
  File "/myenv/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 126, in update_host
    "Could not parse hostname from URL '{}'".format(url))
ValueError: Could not parse hostname from URL 'http://'

Steps to reproduce

import aiohttp

async def process():
    url = 'http://999pokers.info/'
    session = aiohttp.ClientSession()
    async with session.get(url) as response:
        print(response)
    session.close()

loop = asyncio.get_event_loop()
loop.run_until_complete(
    process()
)
loop.close()

Your environment

Python 3.6.0b2
Ubuntu 16.10
aiohttp==2.2,5
Also happens with aiohttp==2.3.0a0 (installed from git on 04/Sep/2017)

@asvetlov
Copy link
Member

asvetlov commented Sep 5, 2017

Agree. Would you provide a Pull Request with introducing a new exception class?

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants