# Store a reference to the backend
self.backend = backend
+ def _configure_proxy(self, request):
+ """
+ Configures the proxy
+ """
+ proxy = self.backend.settings.get("proxy")
+ if not proxy:
+ return
+
+ # Split the configuration value
+ host, delim, port = proxy.partition(":")
+
+ # Convert port to integer
+ # Set port
+ try:
+ port = int(port)
+ except (TypeError, ValueError):
+ log.error("Could not decode proxy setting: %s" % proxy)
+ return
+
+ # Set values
+ request.proxy_host, request.proxy_port = host, port
+
async def fetch(self, request, **kwargs):
"""
Sends a request
if not isinstance(request, HTTPRequest):
request = HTTPRequest(url=request, **kwargs)
+ # Configure the proxy
+ self._configure_proxy(request)
+
# Set User-Agent
request.user_agent = "PakfireBuildService/%s" % self.backend.version
response = await super().fetch(request)
# Log any errors
- except torando.httpclient.HTTPError as e:
+ except tornado.httpclient.HTTPError as e:
log.error("Received status %s:" % e.code)
# Log the response body