juju-solutions / jujuresources

Manage binary resources for charms
MIT License
2 stars 4 forks source link

501 not implemented error when using https proxy #11

Closed merlijn-sebrechts closed 8 years ago

merlijn-sebrechts commented 9 years ago

Class PyPIResource(URLResource) gets the index from https://pypi.python.org/simple/. Long story short, acessing an https:// url via an https proxy causes this nasty python bug to surface.

Because of this, resources cannot be downloaded when using an https proxy. You get the following error message:

Error fetching index https://pypi.python.org/simple/: 501 (Not Implemented)
merlijn-sebrechts commented 9 years ago

A solution for this would be to use urllib2. Following code fragment works behind the proxy:

from urllib2 import Request, urlopen
import urllib

r = Request(url='https://pypi.python.org/simple/')
print urlopen(r).read()
johnsca commented 9 years ago

Excellent catch, thanks. We had this crop up a couple of times but didn't have the resources to sort it out at the time. The linked issue mentions setting https_proxy to a non-SSL-supporting proxy, which would make sense, but are you seeing it with a proper HTTPS proxy?

Switching it to urllib2 seems reasonable, though I've also been thinking that we really ought to remove the manual mirroring behavior and switch to a more general caching proxy solution and relying on the Juju proxy functionality instead of having a manual config option for it.

merlijn-sebrechts commented 9 years ago

It is possible the proxy doesn't support https, although I do not know how I could verify this. using urllib or tools like wget works. I have a hacky port to urllib2, might be a good basis to start from. I'll add it to this issue.

2015-10-21 19:05 GMT+02:00 Cory Johns notifications@github.com:

Excellent catch, thanks. We had this crop up a couple of times but didn't have the resources to sort it out at the time. The linked issue mentions setting https_proxy to a non-SSL-supporting proxy, which would make sense, but are you seeing it with a proper HTTPS proxy?

Switching it to urllib2 seems reasonable, though I've also been thinking that we really ought to remove the manual mirroring behavior and switch to a more general caching proxy solution and relying on the Juju proxy functionality instead of having a manual config option for it.

— Reply to this email directly or view it on GitHub https://github.com/juju-solutions/jujuresources/issues/11#issuecomment-149964146 .

merlijn-sebrechts commented 8 years ago

I'm not sure how to link a branch correctly. This is it:

https://github.com/galgalesh/jujuresources

kwmonroe commented 8 years ago

This has been resolved with PR #15. Thanks for the report (and suggested fix) Merlijn!