[issue22041] http POST request with python 3.3 through web proxy

Demian Brecht report at bugs.python.org
Thu Jul 24 04:59:21 CEST 2014


Demian Brecht added the comment:

Hi Alejandro,

I've spent a little time looking into this. I haven't been able to reproduce what you're seeing on Windows exactly, but I've encountered other issues along the same path using a local squid instance (localhost:4242):


from http.client import OK, HTTPConnection
import unittest

class TestProxy(unittest.TestCase):
    def test_proxy_tunnel_success(self):
        con = HTTPConnection('localhost', 4242)
        con.set_tunnel('www.example.com')
        con.request('GET', 'http://www.example.com')
        resp = con.getresponse()
        self.assertEqual(resp.code, 200)
        data = resp.read()
        con.close()

    def test_proxy_tunnel_failure(self):
        con = HTTPConnection('localhost', 4242)
        con.set_tunnel('www.example.com')
        con.request('GET', '/')
        resp = con.getresponse()
        self.assertEqual(resp.code, 200) # FAILS
        con.close()

if __name__ == '__main__':
    unittest.main()


As you can see with the test above, if I use the full URI, the request succeeds, but the relative path (as in your example) fails. My assumption is that these issues may be related to proxy server implementations, but I'd have to some further investigation before being able to go on more than a hunch (and I don't have time to do that tonight).

As a first step, could you please try using a full URI in your request and see if that produces the desired result?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22041>
_______________________________________


More information about the Python-bugs-list mailing list