hio.core.http.clienting
hio.core.http.clienting module
nonblocking http client
Module Contents
Classes
Nonblocking HTTP Client Requester class |
|
Nonblocking HTTP Client Respondent class |
|
Client class nonblocking HTTP client connection manager and HTTP client |
|
HTTP Client Doer |
Functions
|
Wrapper to create and open HTTP Client instances |
|
Perform Async ReST request to Backend Server |
Attributes
- class hio.core.http.clienting.Requester(hostname='127.0.0.1', port=None, scheme='http', method='GET', path='/', qargs=None, fragment='', headers=None, body=b'', data=None, fargs=None)[source]
Bases:
objectNonblocking HTTP Client Requester class
- reinit(self, hostname=None, port=None, scheme=None, method=None, path=None, qargs=None, fragment=None, headers=None, body=None, data=None, fargs=None)[source]
Reinitialize anything that is not None This enables creating another request on a connection to the same host port
- class hio.core.http.clienting.Respondent(redirects=None, redirectable=True, events=None, retry=None, leid=None, **kwa)[source]
Bases:
hio.core.http.httping.ParsentNonblocking HTTP Client Respondent class
- reinit(self, redirectable=None, **kwa)[source]
Reinitialize Instance See super class redirectable means allow redirection
- checkPersisted(self)[source]
Checks headers to determine if connection should be kept open until server closes it Sets the .persisted flag
- hio.core.http.clienting.openClient(cls=None, **kwa)[source]
Wrapper to create and open HTTP Client instances When used in with statement block, calls .close() on exit of with block
- Parameters
instance (cls is Class instance of subclass) –
- Usage:
- with openClient() as client0:
client0.accept()
- with openClient(cls=Client) as client0:
client0.accept()
- class hio.core.http.clienting.Client(connector=None, requester=None, respondent=None, name='', uid=0, bufsize=8096, wl=None, hostname='127.0.0.1', port=None, scheme='', method='GET', path='/', headers=None, qargs=None, fragment='', body=b'', data=None, fargs=None, requests=None, msg=None, dictable=None, events=None, redirectable=True, redirects=None, responses=None, **kwa)[source]
Client class nonblocking HTTP client connection manager and HTTP client request and response processor
- wind(self, tymth)[source]
Inject new tymist.tymth as new ._tymth. Changes tymist.tyme base. Updates winds .tymer .tymth
- static attrify(response)[source]
Convert response dict into named tuple Response so can access fields as attributes
- request(self, method=None, path=None, qargs=None, fragment=None, headers=None, body=None, data=None, fargs=None, reply=None, **kwa)[source]
Create and append request dict onto .requests with updated values from parameters. Use existing .requester values if not provided except for body. Body/Data/fargs must be newly provided. This is a differential request that reuses latest values if not changed. Requires that patron already be setup with scheme host port
- request = dict([(‘method’, method),
(‘path’, path), (‘qargs’, dict([(“auth”, self.token.value)])), (‘headers’, dict([(‘Accept’, ‘application/json’),
(‘Connection’, ‘Keep-Alive’), (‘Keep-Alive’, ‘timeout=60, max=100’), ])),
(‘body’, body), (‘reply’, dict([(‘rid’, rid), (‘rdeck’, replies)])), ])
self.patron.value.requests.append(request)
- transmit(self, method=None, path=None, qargs=None, fragment=None, headers=None, body=None, data=None, fargs=None, **kwa)[source]
Rebuild and transmit request Assumes that .waited is not True. Do not use bare unless know that there is no current request/reponse in process otherwise it clobbers .requester attributes
If the parameters are all None then use existing .requester and .respondent attributes otherwise reinit .requester and .respondent if method is not None
Should only use with all None first time after that change one of the parameters.
- serviceWhileGen(self, tymeout=0.5)[source]
Generator Method. ServiceAll while pending requests or not a response or not tymeout
Usage: response = yield from .serviceWhileGen(tymeout=0.5)
Runs one iteration of .service() on next and yields empty bytes while not done.
Assumes associated tymist is advanced and realtime sleep delay is incurred elsewhere.
Returns response as namedtuple or None if tymeout.
- hio.core.http.clienting.backendRequest(tymth, *, method='GET', scheme='', host='localhost', port=None, path='/', qargs=None, data=None, buffered=False, tymeout=2.0)[source]
Perform Async ReST request to Backend Server
Parameters:
Usage: (Inside a generator function)
response = yield from backendRequest()
response is the response if valid else None before response is completed the yield from yields up an empty string ‘’ once completed then response has a value
path can be full url with host port etc path takes precedence over others
- class hio.core.http.clienting.ClientDoer(client, **kwa)[source]
Bases:
hio.base.doing.DoerHTTP Client Doer
See Doer for inherited attributes, properties, and methods.
- .client is HTTP Client instance