hio.core.http.serving

hio.core.http.serving classes

nonblocking http server

Module Contents

Classes

Requestant

Nonblocking HTTP Server Requestant class

Responder

Nonblocking HTTP WSGI Responder class

Server

Server WSGI HTTP Server Class

CustomResponder

Nonblocking HTTP Server Response class for non-wsgi applications

Steward

Manages the associated requestant and responder for an incoming connection

BareServer

BareServer class nonblocking Bare (non-WSGI) HTTP server

StaticSink

Class that provides Falcon sink endpoint for serving static files in support

ServerDoer

HTTP WSGI Server Doer

Functions

openServer(cls=None, **kwa)

Wrapper to create and open HTTP Server instances

Attributes

logger

CRLF

LF

CR

WsgiServer

hio.core.http.serving.logger[source]
hio.core.http.serving.CRLF = b'\r\n'[source]
hio.core.http.serving.LF = b'\n'[source]
hio.core.http.serving.CR = b'\r'[source]
class hio.core.http.serving.Requestant(remoter=None, **kwa)[source]

Bases: hio.core.http.httping.Parsent

Nonblocking HTTP Server Requestant class Parses request msg

checkPersisted(self)[source]

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

parseHead(self)[source]

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

parseBody(self)[source]

Parse body

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

Nonblocking HTTP WSGI Responder class

HttpVersionString[source]
Delay = 1.0[source]
close(self)[source]

Close any resources

reset(self, environ, chunkable=None)[source]

Reset attributes for another request-response

build(self)[source]

Return built head bytes from .status and .headers

write(self, msg)[source]

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

start(self, status, response_headers, exc_info=None)[source]

WSGI application start_response callable

Parameters:

status is string of status code and status reason ‘200 OK’ or simple

status code int which will be replaced with string

response_headers is list of tuples of strings of the form (field, value)

one tuple for each header example: [

(‘Content-type’, ‘text/plain’), (‘X-Some-Header’, ‘value’)

]

exc_info is optional exception info if exception occurred while

processing request in wsgi application If exc_info is supplied, and no HTTP headers have been output yet, start_response should replace the currently-stored HTTP response headers with the newly-supplied ones, thus allowing the application to “change its mind” about the output when an error has occurred.

However, if exc_info is provided, and the HTTP headers have already been sent, start_response must raise an error, and should re-raise using the exc_info tuple. That is:

raise exc_info[1].with_traceback(exc_info[2]) (python3)

Nonstandard modifiction to allow for iterable/generator of body to change

headers and status before first write to support async processing of responses whose iterator/generator yields empty before first non-empty yield. In .service yielding empty does not cause write so status line and headers are not sent until first non-empty write.

The mode is that the app.headers and app.status are consulted to see if changed from when .start = wsgi start_response was first called.

service(self)[source]

Service wsgi compatible application

hio.core.http.serving.openServer(cls=None, **kwa)[source]

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)[source]

Server WSGI HTTP Server Class

Tymeout = 5.0[source]
wind(self, tymth)[source]

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

reopen(self)[source]

Return result of .servant.reopen()

close(self)[source]

Close all reqs, reps, and ixes

idle(self)[source]

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

buildEnviron(self, requestant)[source]

Returns wisgi environment dictionary for supplied requestant

closeConnection(self, ca)[source]

Close and remove connection given by ca

serviceConnects(self)[source]

Service new incoming connections Create requestants Timeout stale connections

serviceReqs(self)[source]

Service pending requestants

serviceReps(self)[source]

Service pending responders

service(self)[source]

Service request response

hio.core.http.serving.WsgiServer[source]
class hio.core.http.serving.CustomResponder(steward=None, status=200, headers=None, body=b'', data=None)[source]

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

HttpVersionString[source]
reinit(self, status=None, headers=None, body=None, data=None)[source]

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

build(self, status=None, headers=None, body=None, data=None)[source]

Build and return response message

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

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

refresh(self)[source]

Restart incomer tymer

respond(self)[source]

Respond to request Override in subclass Echo request

pour(self)[source]

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)[source]

BareServer class nonblocking Bare (non-WSGI) HTTP server Define CustomResponder subclass to respond to requests as per Steward

Timeout = 5.0[source]
reopen(self)[source]

Return result of .servant.reopen()

idle(self)[source]

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

close(self)[source]

Close all ixes for all stewards

closeConnection(self, ca)[source]

Close and remove connection and associated steward given by ca

serviceConnects(self)[source]

Service new incoming connections Create requestants Timeout stale connections

serviceStewards(self)[source]

Service pending requestants and responders

service(self)[source]

Service request response

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

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

StaticSinkBasePath = /static[source]
DefaultStaticSinkBasePath = /[source]
__call__(self, req, rep)[source]
class hio.core.http.serving.ServerDoer(server, **kwa)[source]

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(self, tymth)[source]

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

enter(self)[source]
recur(self, tyme)[source]
exit(self)[source]