morgoth / picasa

Simple google picasa management
https://github.com/morgoth/picasa/
MIT License
80 stars 41 forks source link

Prevent setting up proxy at load time #27

Closed paulvt closed 10 years ago

paulvt commented 10 years ago

In our application we use libproxy to be able to support all kinds of weird proxy setups. Using libproxy this means that the https_proxy environment can contain "wpad://" or "pac+http://host/some/pac_file.pac".

While IMO the Picasa library shouldn't be have to support or use libproxy, I think it shouldn't crash loadtime:

/usr/lib/ruby/1.8/uri/common.rb:406:in `split': bad URI(absolute but no path): wpad:// (URI::InvalidURIError)
    from /usr/lib/ruby/1.8/uri/common.rb:485:in `parse'
    from /usr/lib/ruby/vendor_ruby/picasa/http.rb:13:in `proxy'
    from /usr/lib/ruby/vendor_ruby/picasa/http.rb:26
    from /usr/lib/ruby/vendor_ruby/picasa.rb:4:in `require'
    from /usr/lib/ruby/vendor_ruby/picasa.rb:4
    from /home/player/LcNarrowCasting/Media/layout/1076/script/Picasa.rb:5:in `require'
    from /home/player/LcNarrowCasting/Media/layout/1076/script/Picasa.rb:5

With other libraries (instagram, flickr, etc.) we usually do a manual setup of the proxy, but we now don't get this far as already the "require" crashes.

morgoth commented 10 years ago

This gem uses URI.parse from Ruby standard library. As you can see wpad:// is invalid URI, that's why error is thrown. I checked second url "pac+http://host/some/pac_file.pac" - it is parsed without error. Why would you want to allow invalid URI in proxy?

paulvt commented 10 years ago

Because URI.parse doesn't handle it, doesn't mean it's an invalid URI. But, indeed, it's a libproxy convention that Picasa shouldn't have to support. Even if the PAC URI is parsed correctly, the proxy is derived by evaluating the request URL in the JS contained in the PAC file, so in this case the URI shouldn't be used. My main problem is that proxy is set at loadtime, not at runtime... I am not sure whether this is related to HTTParty's way of setting up things, but al other social media libs I use allow for runtime proxy setup.

morgoth commented 10 years ago

httparty options are added at load time: https://github.com/morgoth/picasa/blob/master/lib/picasa/http.rb#L26 I think it should be possible to setup those options at run time. I will investigate it