hio.core.http.serving ===================== .. py:module:: hio.core.http.serving .. autoapi-nested-parse:: hio.core.http.serving classes nonblocking http server Module Contents --------------- .. py:class:: Requestant(remoter=None, **kwa) Bases: :py:obj:`hio.core.http.httping.Parsent` Nonblocking HTTP Server Requestant class Parses request msg .. py:method:: checkPersisted() Checks headers to determine if connection should be kept open until client closes it Sets the .persisted flag .. py:method:: parseHead() Generator to parse headers in heading of .msg Yields None if more to parse Yields True if done parsing .. py:method:: parseBody() Parse body .. py:class:: Responder(incomer, app, environ, chunkable=False, delay=None) Nonblocking HTTP WSGI Responder class .. py:method:: close() Close any resources .. py:method:: reset(environ, chunkable=None) Reset attributes for another request-response .. py:method:: build() Return built head bytes from .status and .headers .. py:method:: write(msg) WSGI write callback This writes out the headers the first time its called otherwise writes the msg bytes .. py:method:: start(status, response_headers, exc_info=None) WSGI application start_response callable. Arguments: - `status`: status string like "200 OK" or integer status code. - `response_headers`: list of (field, value) tuples. - `exc_info`: optional exception info; if headers already sent, re-raise. Nonstandard modification: allow iterables or generators to update headers and status before the first non-empty write. In `.service`, empty yields do not write, so headers are sent on the first non-empty write. The app consults `app.headers` and `app.status` at that time. .. py:method:: service() Service wsgi compatible application .. py:function:: openServer(cls=None, **kwa) Wrapper to create and open HTTP Server instances When used in with statement block, calls .close() on exit of with block :param cls is Class instance of subclass instance: Usage: with openServer() as server0: server0. with openServer(cls=BareServer) as server0: server0. .. py:class:: Server(name='hio.wsgi.server', app=None, reqs=None, reps=None, servant=None, bufsize=8096, wl=None, ha=None, host='', port=None, eha=None, scheme='', tymeout=None, **kwa) Server WSGI HTTP Server Class .. py:method:: wind(tymth) Inject new tymist.tymth as new ._tymth. Changes tymist.tyme base. Updates winds .tymer .tymth .. py:method:: reopen(**kwa) Return result of .servant.reopen() .. py:method:: close() Close all reqs, reps, and ixes .. py:method:: idle() Returns True if no connections have requests in process Useful for debugging .. py:method:: buildEnviron(requestant) Returns wisgi environment dictionary for supplied requestant .. py:method:: closeConnection(ca) Close and remove connection given by ca .. py:method:: serviceConnects() Service new incoming connections Create requestants Timeout stale connections .. py:method:: serviceReqs() Service pending requestants .. py:method:: serviceReps() Service pending responders .. py:method:: service() Service request response .. py:class:: CustomResponder(steward=None, status=200, headers=None, body=b'', data=None) Nonblocking HTTP Server Response class for non-wsgi applications Used by Steward HTTP/1.1 200 OK Content-Length: 122 Content-Type: application/json Date: Thu, 30 Apr 2015 19:37:17 GMT Server: IoBook.local .. py:method:: reinit(status=None, headers=None, body=None, data=None) Reinitialize anything that is not None This enables creating another response on a connection .. py:method:: build(status=None, headers=None, body=None, data=None) Build and return response message .. py:class:: Steward(remoter, requestant=None, responder=None, dictable=False) Manages the associated requestant and responder for an incoming connection for BareServer (non-wsgi) HTTP server .. py:method:: refresh() Restart incomer tymer .. py:method:: respond() Respond to request Override in subclass Echo request .. py:method:: pour() Run generator to stream response message .. py:class:: BareServer(servant=None, stewards=None, name='', bufsize=8096, wl=None, ha=None, host='', port=None, eha=None, scheme='', dictable=False, timeout=None, **kwa) BareServer class nonblocking Bare (non-WSGI) HTTP server Define CustomResponder subclass to respond to requests as per Steward .. py:method:: reopen(**kwa) Return result of .servant.reopen() .. py:method:: idle() Returns True if no connections have requests in process Useful for debugging .. py:method:: close() Close all ixes for all stewards .. py:method:: closeConnection(ca) Close and remove connection and associated steward given by ca .. py:method:: serviceConnects() Service new incoming connections Create requestants Timeout stale connections .. py:method:: serviceStewards() Service pending requestants and responders .. py:method:: service() Service request response .. py:class:: StaticSink(staticDirPath=None) Class that provides Falcon sink endpoint for serving static files in support of a client side web app. .. py:class:: ServerDoer(server, **kwa) Bases: :py:obj:`hio.base.doing.Doer` HTTP WSGI Server Doer See Doer for inherited attributes, properties, and methods. .. attribute:: .server is HTTP WSGI Server instance Properties: .. py:method:: wind(tymth) Inject new tymist.tymth as new ._tymth. Changes tymist.tyme base. Updates winds .tymer .tymth .. py:method:: enter(*, temp=None) Do 'enter' context actions. Override in subclass. Not a generator method. Set up resources. Comparable to context manager enter. :param temp: True means use temporary file resources if any None means ignore parameter value. Use self.temp :type temp: bool | None Inject temp or self.temp into file resources here if any Doist or DoDoer winds its doers on enter .. py:method:: recur(tyme) Service the HTTP server once per recurrence. .. py:method:: exit() Do 'exit' context actions. Override in subclass. Not a generator method. Clean up resources. Comparable to context manager exit. Called by finally after normal return, close, or abort. After .exit() do returns resulting in StopIteration.