aio-libs / aiohttp

Asynchronous HTTP client/server framework for asyncio and Python
https://docs.aiohttp.org
Other
15.12k stars 2.02k forks source link

URL with # in response #1314

Closed Fahreeve closed 6 years ago

Fahreeve commented 8 years ago

Long story short

url address of original response looks like http://someurl.bla/test.html#access_token=blabla&ab=1 but in aiohttp response.url I can see only http://someurl.bla/test.html

Expected behaviour

I want to have a full address in response.url

Actual behaviour

response.url has only this part: http://someurl.bla/test.html

asvetlov commented 8 years ago

This is intended behavior. See #846

Fahreeve commented 8 years ago

have I simple way how to change it back?

asvetlov commented 8 years ago

No response contains real URL sent to server. If you want keep unmodified version -- please save it in your own storage manually.

Fahreeve commented 8 years ago

I don't agree with you You can see an example in this page: https://vk.com/dev/implicit_flow_user in point 3

Fahreeve commented 8 years ago

For my library I'm using this code:

class CustomClientResponse(aiohttp.ClientResponse):

    async def start(self, connection, read_until_eof=False):
        await super().start(connection, read_until_eof)
        headers = CIMultiDict(self.headers)
        location = headers.get(hdrs.LOCATION, None)
        if location is not None:
            headers[hdrs.LOCATION] = location.replace('#', '?')
        self.headers = CIMultiDictProxy(headers)
        self.raw_headers = tuple(headers.items())
        return self
asvetlov commented 8 years ago

Please correct me if I'm wrong: VK API does rely on fragment data and there is no way to do it via current aiohttp client API. Is it correct?

Fahreeve commented 8 years ago

VK API does relay on fragment data

я не могу понять эту фразу на английском, но полагаю, что вы поймете меня на русском проблема в том, что при успешной авторизации в соц. сети происходит перенаправление на адрес https://oauth.vk.com/blank.html#access_token= 533bacf01e11f55b536a565b57531ad114461ae8736d6506a3&expires_in=86400&user_id=8492&state=123456 в версии 0.21.6 все работало, но потом я обновился до 1.0.3 и все что после # перестало было доступным в переменных history или url объекта response

rutsky commented 8 years ago

I think @asvetlov intended to say "VK API does rely on fragment data" ("VK API зависит от передачи фрагмента (части после #) браузером серверу").

@Fahreeve I believe you missed somewhere escaping of # in URI. Can you show the code that you use for step 1 in mentined docs, e.g. to construct URI such as this?

https://oauth.vk.com/authorize?client_id=1&display=page&redirect_uri=http://example.com/callback&scope=friends&response_type=token&v=5.59
Fahreeve commented 8 years ago

@rutsky https://github.com/Fahreeve/aiovk/blob/master/aiovk/sessions.py#L99 it don't help you you have to use debuger in this moment https://github.com/Fahreeve/aiovk/blob/master/aiovk/sessions.py#L127 and watch out for history variable

fafhrd91 commented 7 years ago

fixed in master

vladarts commented 7 years ago

Hello!

I have same problem with VK api. version 1.3.0 - I dont see fragment in result. Checked hack from @Fahreeve - it works.

fafhrd91 commented 7 years ago

@asvetlov we need to fix this sh..

fafhrd91 commented 7 years ago

is this still a problem? do we have any idea what needs to be fixed?

asvetlov commented 6 years ago

Close as outdated

webknjaz commented 6 years ago

@asvetlov you should really consider enabling stale bot integration: https://github.com/apps/stale

asvetlov commented 6 years ago

We can manage our all 100 open issues without bots. There are many very old ones which should stay in tracker as an appointment at least, I don't want to be very aggressive on issues rejecting

webknjaz commented 6 years ago

@asvetlov that bot supports ignoring issues marked with certain labels :) It's pretty configurable

asvetlov commented 6 years ago

You can try to setup it and let's look how things are going.

lock[bot] commented 5 years ago

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.