Followup-For: Bug #801136
Package: mpd-sima
Tags: patch, confirmed

Here is a patch, it should merge available HTTPS?_PROXIES variables.
I will patch the debian package if it takes too long to release the next
upstream version including this fix.

I haven't fully tested the solution yet.
Don't hesitate to give it a try, the patch should merge fine on 0.13.

I'll have a look at the packaging part later.

Cheers
Geoff

Le 10/10/2015 15:07, Geoff a écrit :
> Hi Chris,
> 
> Thanks very much for your report :)
> 
> Two issues then :
> 
> [packaging] http proxies env. var should be exposed when using
> systemd/SystV.
> 
> [upstream] the http client should actually use them ^^
> The http client bug was forwarded upstream, the issue is
> identified/nearly fixed. Python requests is actually not honoring
> HTTP_PROXY because of the use of the lower level API in the http client
> which in turn is not propagating environment variables…
> 
> I'll try to fix this as soon as I can (I'm also the upstream developer).
> 
> Thanks again.
> Geoff
> 
> The 06/10/2015 17:46, Chris Chiappa wrote :
>> […]
>> Behind a proxy, I've found it very difficult to get mpd-sima to use it
>> for last.fm access.  python-requests documentation at
>> http://docs.python-requests.org/en/latest/ says it should pay
>> attention to the HTTP_PROXY and HTTPS_PROXY environment variables.  I
>> created /etc/systemd/system/mpd-sima.service.d/override.conf
>> with
>>
>> [Service]
>> Environment="HTTP_PROXY=http://proxy.company.com:80";
>> Environment="HTTPS_PROXY=http://proxy.company.com:80";
>>
>> and restarted mpd-sima.  In /proc/<pid>/environ I can see both
>> environment variables, but from both strace and mpd-sima's log I can
>> see that it's failing to connect to last.fm.  I was able to get it to
>> work by hacking fetch_ws in http.py and manually specifying proxies:
>>
>>     @Throttle(WAIT_BETWEEN_REQUESTS)
>>         def fetch_ws(self, prepreq):
>>             proxies = {
>>                 "http"  : "http://proxy.company.com:80";,
>>                 "https" : "http://proxy.company.com:80";
>>             }
>>             """fetch from web service"""
>>             sess = Session()
>>             sess.proxies = proxies
>>             resp = sess.send(prepreq, timeout=SOCKET_TIMEOUT)
>>     ...
>>
>> but that's obviously not the right way to do it.  Not being a python
>> hacker I'm not sure how to tell why the envrironment variables aren't
>> working, but it seems like having some better way of configuring
>> proxies might be desirable anyhow.
> 
diff --git a/sima/lib/http.py b/sima/lib/http.py
index 0c1b396..10fae9c 100644
--- a/sima/lib/http.py
+++ b/sima/lib/http.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2014 Jack Kaliko <kal...@azylum.org>
+# Copyright (c) 2014-2015 Jack Kaliko <kal...@azylum.org>
 # Copyright (c) 2012, 2013 Eric Larson <e...@ionrock.org>
 #
 #   This program is free software: you can redistribute it and/or modify
@@ -301,7 +301,8 @@ class HttpClient:
     def fetch_ws(self, prepreq):
         """fetch from web service"""
         sess = Session()
-        resp = sess.send(prepreq, timeout=SOCKET_TIMEOUT)
+        settings = sess.merge_environment_settings(prepreq.url, {}, None, False, None)
+        resp = sess.send(prepreq, timeout=SOCKET_TIMEOUT, **settings)
         if resp.status_code == 304:
             self.stats.update(etag=self.stats.get('etag')+1)
             resp = self.controller.update_cached_response(prepreq, resp)

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
pkg-multimedia-maintainers mailing list
pkg-multimedia-maintainers@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-multimedia-maintainers

Reply via email to