hio.core.http.serving

hio.core.http.serving classes

nonblocking http server

Module Contents

class hio.core.http.serving.Requestant(remoter=None, **kwa)

Bases: hio.core.http.httping.Parsent

Nonblocking HTTP Server Requestant class Parses request msg

checkPersisted()

Checks headers to determine if connection should be kept open until client closes it Sets the .persisted flag

parseHead()

Generator to parse headers in heading of .msg Yields None if more to parse Yields True if done parsing

parseBody()

Parse body

class hio.core.http.serving.Responder(incomer, app, environ, chunkable=False, delay=None)

Nonblocking HTTP WSGI Responder class

close()

Close any resources

reset(environ, chunkable=None)

Reset attributes for another request-response

build()

Return built head bytes from .status and .headers

write(msg)

WSGI write callback This writes out the headers the first time its called otherwise writes the msg bytes

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.

service()

Service wsgi compatible application

hio.core.http.serving.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

Parameters:

instance (cls is Class instance of subclass)

Usage:
with openServer() as server0:

server0.

with openServer(cls=BareServer) as server0:

server0.

class hio.core.http.serving.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

wind(tymth)

Inject new tymist.tymth as new ._tymth. Changes tymist.tyme base. Updates winds .tymer .tymth

reopen(**kwa)

Return result of .servant.reopen()

close()

Close all reqs, reps, and ixes

idle()

Returns True if no connections have requests in process Useful for debugging

buildEnviron(requestant)

Returns wisgi environment dictionary for supplied requestant

closeConnection(ca)

Close and remove connection given by ca

serviceConnects()

Service new incoming connections Create requestants Timeout stale connections

serviceReqs()

Service pending requestants

serviceReps()

Service pending responders

service()

Service request response

class hio.core.http.serving.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

reinit(status=None, headers=None, body=None, data=None)

Reinitialize anything that is not None This enables creating another response on a connection

build(status=None, headers=None, body=None, data=None)

Build and return response message

class hio.core.http.serving.Steward(remoter, requestant=None, responder=None, dictable=False)

Manages the associated requestant and responder for an incoming connection for BareServer (non-wsgi) HTTP server

refresh()

Restart incomer tymer

respond()

Respond to request Override in subclass Echo request

pour()

Run generator to stream response message

class hio.core.http.serving.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

reopen(**kwa)

Return result of .servant.reopen()

idle()

Returns True if no connections have requests in process Useful for debugging

close()

Close all ixes for all stewards

closeConnection(ca)

Close and remove connection and associated steward given by ca

serviceConnects()

Service new incoming connections Create requestants Timeout stale connections

serviceStewards()

Service pending requestants and responders

service()

Service request response

class hio.core.http.serving.StaticSink(staticDirPath=None)

Class that provides Falcon sink endpoint for serving static files in support of a client side web app.

class hio.core.http.serving.ServerDoer(server, **kwa)

Bases: hio.base.doing.Doer

HTTP WSGI Server Doer

See Doer for inherited attributes, properties, and methods.

.server is HTTP WSGI Server instance

Properties:

wind(tymth)

Inject new tymist.tymth as new ._tymth. Changes tymist.tyme base. Updates winds .tymer .tymth

enter(*, temp=None)

Do ‘enter’ context actions. Override in subclass. Not a generator method. Set up resources. Comparable to context manager enter.

Parameters:

temp (bool | None) – True means use temporary file resources if any None means ignore parameter value. Use self.temp

Inject temp or self.temp into file resources here if any

Doist or DoDoer winds its doers on enter

recur(tyme)

Service the HTTP server once per recurrence.

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.