# Uri module uses CONNECT instead of GET when going through a proxy and fails

**URL:** <https://forum.ansible.com/t/uri-module-uses-connect-instead-of-get-when-going-through-a-proxy-and-fails/20752>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [March 2, 2016, 5:00pm UTC](https://forum.ansible.com/t/uri-module-uses-connect-instead-of-get-when-going-through-a-proxy-and-fails/20752 "2016-03-02T17:00:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benoit\_Tremblay](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@Benoit\_Tremblay](https://forum.ansible.com/u/Benoit_Tremblay)\
**Post date:** [March 2, 2016, 5:00pm UTC](https://forum.ansible.com/t/uri-module-uses-connect-instead-of-get-when-going-through-a-proxy-and-fails/20752/1 "2016-03-02T17:00:36Z")

</div>

I have a problem using uri when behind a proxy. There is an exception in the python module.  
This works well when not going through a proxy. But fails when a proxy is set.

- uri: url=“[http://www.google.com](http://www.google.com)” dest=“/tmp/tempfile”

fatal: [h39]: FAILED! =\> {“changed”: false, “failed”: true, “invocation”: {“module\_name”: “uri”}, “module\_stderr”: “”, “module\_stdout”: “Traceback (most recent call last):\r\n File "/root/.ansible/tmp/ansible-tmp-1456764961.49-135649813587956/uri", line 2439, in \r\n main()\r\n File "/root/.ansible/tmp/ansible-tmp-1456764961.49-135649813587956/uri", line 453, in main\r\n resp, content, dest = uri(module, url, dest, user, password, body, body\_format, method, dict\_headers, redirects, socket\_timeout, validate\_certs)\r\n File "/root/.ansible/tmp/ansible-tmp-1456764961.49-135649813587956/uri", line 340, in uri\r\n resp, content = h.request(url, method=method, body=body, headers=headers) \r\n File "/usr/local/lib/python2.7/dist-packages/httplib2/ **init**.py", line 1609, in request\r\n (response, content) = self.\_request(conn, authority, uri, request\_uri, method, body, headers, redirections, cachekey)\r\n File "/usr/local/lib/python2.7/dist-packages/httplib2/ **init**.py", line 1351, in \_request\r\n (response, content) = self.\_conn\_request(conn, request\_uri, method, body, headers)\r\n File "/usr/local/lib/python2.7/dist-packages/httplib2/ **init**.py", line 1272, in \_conn\_request\r\n conn.connect()\r\n File "/usr/local/lib/python2.7/dist-packages/httplib2/ **init**.py", line 916, in connect\r\n self.sock.connect((self.host, self.port) + sa[2:])\r\n File "/usr/local/lib/python2.7/dist-packages/httplib2/socks.py", line 424, in connect\r\n self.\_\_negotiatehttp(destpair[0], destpair[1])\r\n File "/usr/local/lib/python2.7/dist-packages/httplib2/socks.py", line 390, in \_\_negotiatehttp\r\n raise HTTPError((statuscode, statusline[2]))\r\nhttplib2.socks.HTTPError: (403, ‘Forbidden’)\r\n”, “msg”: “MODULE FAILURE”, “parsed”: false}

When listening on my proxy server, I realized that uri is trying to HTTP CONNECT to google, rather that using GET. I compared with what wget or curl are doing and both of them are sending GET to the proxy.

Anyone has faced the same issue?

I am using version 2.0.0.1 of Ansible.  
The remote node is running ubuntu 14.04.04

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [March 2, 2016, 5:29pm UTC](https://forum.ansible.com/t/uri-module-uses-connect-instead-of-get-when-going-through-a-proxy-and-fails/20752/2 "2016-03-02T17:29:55Z")

</div>

I think this is likely fixed in devel/2.1.

The `uri` module previously relied on httplib2. That dependency has been removed and `uri` now utilizes the shared code from `ansible.module_utils.urls` that `get_url` and many other modules have been using for some time now.

---

<div class="post-metadata">

**Author:** ![Benoit\_Tremblay](https://avatars.discourse-cdn.com/v4/letter/b/2acd7d/32.png) [@Benoit\_Tremblay](https://forum.ansible.com/u/Benoit_Tremblay)\
**Post date:** [March 2, 2016, 9:31pm UTC](https://forum.ansible.com/t/uri-module-uses-connect-instead-of-get-when-going-through-a-proxy-and-fails/20752/3 "2016-03-02T21:31:46Z")

</div>

Thanks!

Benoit
