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

HTTP GET + compress=True = 501 #117

Closed
a-urth opened this issue Jul 15, 2014 · 10 comments
Closed

HTTP GET + compress=True = 501 #117

a-urth opened this issue Jul 15, 2014 · 10 comments

Comments

@a-urth
Copy link
Contributor

a-urth commented Jul 15, 2014

There are some strange behavior with proxies. Trying to do HTTP GET request, requests package gives correct result, asyncio - 501.

Response headers:
SERVER - squid/3.1.4
MIME-VERSION - 1.0
DATE - Mon, 14 Jul 2014 20:20:15 GMT
CONTENT-TYPE - text/html
CONTENT-LENGTH - 3136
X-SQUID-ERROR - ERR_UNSUP_REQ 0
VIA - 1.0 host (squid/3.1.4)

Proxy - 173.234.226.20:8800

Seems that GET method for such proxy is incorrect, even if request done through http.
Any suggestions?

@popravich
Copy link
Member

Can you add code showing how you are making the request?

I've just tryied the following code and both requests and aiohttp got 403 (consider this is ok):

>>> import asyncio
>>> import aiohttp
>>> import requests

>>> loop = asyncio.get_event_loop()
>>> resp = loop.run_until_complete(
...    aiohttp.request('GET', 'http://httpbin.org',
...                    connector=aiohttp.ProxyConnector('http://173.234.226.20:8800')))
>>> resp
... <ClientResponse [403 Forbidden]>

>>> requests.get('http://httpbin.org', proxies={'http': '173.234.226.20:8800'})
... <Response [403]>

@a-urth
Copy link
Contributor Author

a-urth commented Jul 15, 2014

Hm... the thing was not in proxy, its about compress=True
Sorry for such inconvenience, is it possible because of firewall?

@asyncio.coroutine
def get(url):
    proxy = random.choice(PROXIES)
    response = yield from aiohttp.request(
        'GET', url, compress=True, connector=aiohttp.ProxyConnector(proxy=proxy)
    )
    print("{0} - {1} - {2}".format(url, response.status))
    return (yield from response.read_and_close())

if __name__ == '__main__':
    # Proxies initializing

    loop = asyncio.get_event_loop()
    tasks = [get(url) for url in get_records()]
    loop.run_until_complete(asyncio.wait([get(url) for url in get_records()]))

@popravich
Copy link
Member

Aha, I see.

Making 'GET'-request with compress=True causes aiohttp to add extra request headers --
Content-encoding: deflate and Transfer-encoding: chunked.
It seems that GET + Transfer-encoding: chunked pair makes squid nervous so its might be buggy aiohttp behavior.

We will into this.

@popravich popravich added the bug label Jul 15, 2014
@a-urth a-urth changed the title HTTP CONNECT not only for SSL HTTP GET + compress=True = 501 Jul 15, 2014
@fafhrd91
Copy link
Member

well, nervous is wrong word, buggy is right :)
we can check in client if there is no body and omit content-encoding and transfer-encoding headers

@fafhrd91
Copy link
Member

is it still the problem?

@danielnelson
Copy link
Contributor

I think it must be still an issue based on comments in #835.

@fafhrd91 fafhrd91 reopened this May 23, 2016
@fafhrd91
Copy link
Member

@danielnelson what to fix it?

@danielnelson
Copy link
Contributor

sure

@asvetlov
Copy link
Member

asvetlov commented Jun 3, 2016

Fixed by #891

@lock
Copy link

lock bot commented Oct 29, 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.

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

No branches or pull requests

5 participants