Commits

Evgeniy Tatarkin  committed 12de7a0

fix UrllibHttpRequest adapter

  • Participants
  • Parent commits 1594fc2

Comments (0)

Files changed (1)

File pomp/contrib/__init__.py

 
     def _fetch(self, request):
         try:
-            res = urlopen(request.url, timeout=self.timeout)
+            res = urlopen(request, timeout=self.timeout)
             return UrllibHttpResponse(request, res)
         except Exception as e:
             log.exception('Exception on %s', request)
         return self.workers_pool.map(self._fetch, requests)
 
 
-class UrllibHttpRequest(BaseHttpRequest):
+class UrllibHttpRequest(Request, BaseHttpRequest):
     """Adapter for urllib request to :class:`pomp.core.base.BaseHttpRequest`""" 
 
-    def __init__(self, url):
-        self.request = url if isinstance(url, Request) else Request(url)
-
     @property
     def url(self):
         return self.request.get_full_url()
     def process_request(self, req):
         if isinstance(req, BaseHttpRequest):
             return req
-        return UrllibHttpRequest(url=req)
+        return UrllibHttpRequest(req)
 
     def process_response(self, response):
         return response