Commits

Lynn Rees committed 0a15e73

- more

Comments (0)

Files changed (3)

wire/http/client.py

 
 from functools import partial
 
+from stuf.utils import exhaust
 from appspace.keys import appifies
-from callchain.chain import inside, LinkedQ
+from callchain.services.apps import events
+from callchain.event import EventQ, einside
 from twoq.lazy.mixins import AutoResultMixin
-from callchain.lazy_auto.event import eventq
+from callchain.services.queue import KResults
 
 from wire.http.agent import Request
 from wire.http.config import Defaults, Required
 from wire.http.keys.client import KRequestClient
-from wire.http.keys.apps import events, request, response
+from wire.http.keys.apps import inrequest, request, xevents
 
 
-@appifies(KRequestClient)
-class http(eventq):
+@appifies(KRequestClient, KResults)
+@einside(inrequest, events)
+class http(EventQ, AutoResultMixin):
 
     '''HTTP client chain'''
 
         _defaults = self.defaults
         # set useragent
         kw['useragent'] = kw.pop('useragent', _defaults.useragent)
-        super(http, self).__init__(request, events, Required, Defaults, **kw)
+        super(http, self).__init__(request, xevents, Required, Defaults, **kw)
         # allow redirects for request
         _setdefault(
             '_redirects', kw.get('redirects', _defaults.follow_redirects),
     _hproxy = proxy
 
     ###########################################################################
-    ## internal management ####################################################
+    ## internal chain management ##############################################
     ###########################################################################
 
     def clear(self):
 
         @param *urls: sequence of URL arguments
         '''
+        kw = dict(
+            # default timeout
+            timeout=config.pop('timeout', self._timeout),
+            # allow redirects
+            redirects=self._redirects,
+            # verify certs
+            verify=self._verify
+        )
         # authentication configuration
         auth = config.pop('auth', self._auth)
         if auth:
             self.auth(*auth)
+        kw['auth'] = auth
         # proxy configuration
         proxy = config.pop('proxy', self._proxy)
         if proxy:
             self.proxy(*proxy)
-        # default timeout
-        timeout = config.pop('timeout', self._timeout)
-        # allow redirects
-        redirects = self._redirects
-        # verify certs
-        verify = self._verify
-        _chain = self._cchain
+        kw['proxy'] = proxy
         useragent = self._h_useragent
         # process url arguments
-        self._chain.extend(_chain(Request(
-            url,
-            useragent,
-            verify=verify,
-            redirects=redirects,
-            timeout=timeout,
-            auth=auth,
-            proxy=proxy,
-        )) for url in urls)
+        exhaust(self._cchain, Request(url, useragent, **kw) for url in urls)
         return self._dcall()
 
     _h_call = __call__
-
-
-@inside(response)
-class Response(LinkedQ, AutoResultMixin):
-
-    '''HTTP response collection'''
-
-    def __init__(self, root):
-        super(response, self).__init__(root)

wire/http/keys/apps.py

 '''wire http appconf'''
 
 from callchain.patterns import Pathways, Nameways
+from wire.talk.apps import talk
 
-from wire.talk.apps import talk, untalk
 
-
-class events(Pathways):
+class xevents(Pathways):
     pass
 
 
-class response(untalk):
+class response(Pathways):
     pass
 
 
-class request(talk):
+class inrequest(talk):
+
+    class map(Nameways):
+        key = 'callchain.services.map.KMap'
+        map = 'callchain.lazy_auto.eventlet.mapevent'
+
     class data(Nameways):
         key = 'wire.http.keys.request.KRequestData'
         data = 'wire.http.request.Data'
         key = 'wire.http.keys.request.KRequestHeader'
         header = 'wire.http.request.Header'
 
+
+class request(talk):
+
+    agent = 'wire.http.agent.Request'
+
     class requestsua(Nameways):
         key = 'wire.http.keys.request.KRequestsUA'
         header = 'wire.http.agents.requestua.Response'
+
+    class response(Nameways):
+        key = 'wire.http.keys.request.KRequestsUA'
+        header = 'wire.http.agents.requestua.Response'

wire/http/request.py

 
 from wire.http.httplet import httplet
 from wire.http.keys.request import KRequestData, KRequestHeaders
+from twoq.lazy.mixins import AutoResultMixin
+from callchain.chain import LinkedQ, inside
+from wire.http.keys.apps import response
 
 
 @appifies(KRequestData)
         return self
 
     _huheader = uheader
+
+
+@inside(response)
+class Response(LinkedQ, AutoResultMixin):
+
+    '''HTTP response collection'''
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.