-
[ Pobierz całość w formacie PDF ]
The maximum size, in bytes, for request bodies, or 0 for no limit.
max_request_header_size= 0
The maximum size, in bytes, for request headers, or 0 for no limit.
maxthreads= None
The maximum number of worker threads to create (default -1 = no limit).
minthreads= None
The minimum number of worker threads to create (default 10).
nodelay= True
If True (the default since 3.1), sets the TCP_NODELAY socket option.
protocol= HTTP/1.1
The version string to write in the Status-Line of all HTTP responses.
For example, HTTP/1.1 is the default. This also limits the supported features used in the response.
ready= False
An internal flag which marks whether the socket is accepting connections.
request_queue_size= 5
The backlog arg to socket.listen(); max queued connections (default 5).
server_name= None
The name of the server; defaults to socket.gethostname().
shutdown_timeout= 5
The total time, in seconds, to wait for worker threads to cleanly exit.
software= None
The value to set for the SERVER_SOFTWARE entry in the WSGI environ.
If None, this defaults to %s Server % self.version.
ssl_adapter= None
An instance of SSLAdapter (or a subclass).
You must have the corresponding SSL driver library installed.
start()
Run the server forever.
stop()
Gracefully shutdown a server that is serving forever.
tick()
Accept a new connection and put it on the Queue.
timeout= 10
The timeout in seconds for accepted connections (default 10).
7.15. cherrypy.wsgiserver 161
CherryPy Documentation, Release 3.2.4
version= CherryPy/3.2.4
A version string for the HTTPServer.
Request Entities
classcherrypy.wsgiserver.SizeCheckWrapper(rfile, maxlen)
Wraps a file-like object, raising MaxSizeExceeded if too large.
classcherrypy.wsgiserver.KnownLengthRFile(rfile, content_length)
Wraps a file-like object, returning an empty string when exhausted.
classcherrypy.wsgiserver.ChunkedRFile(rfile, maxlen, bufsize=8192)
Wraps a file-like object, returning an empty string when exhausted.
This class is intended to provide a conforming wsgi.input value for request entities that have been encoded with
the chunked transfer encoding.
classcherrypy.wsgiserver.CP_fileobject(*args, **kwargs)
Faux file object attached to a socket object.
sendall(data)
Sendall for non-blocking sockets.
Exceptions
classcherrypy.wsgiserver.MaxSizeExceeded
classcherrypy.wsgiserver.NoSSLError
Exception raised when a client speaks HTTP to an HTTPS socket.
classcherrypy.wsgiserver.FatalSSLAlert
Exception raised when the SSL implementation signals a fatal alert.
Thread Pool
classcherrypy.wsgiserver.WorkerThread(server)
Thread which continuously polls a Queue for Connection objects.
Due to the timing issues of polling a Queue, a WorkerThread does not check its own ready flag after it has
started. To stop the thread, it is necessary to stick a _SHUTDOWNREQUEST object onto the Queue (one for
each running WorkerThread).
conn= None
The current connection pulled off the Queue, or None.
ready= False
A simple flag for the calling server to know when this thread has begun polling the Queue.
server= None
The HTTP Server which spawned this thread, and which owns the Queue and is placing active connections
into it.
classcherrypy.wsgiserver.ThreadPool(server, min=10, max=-1)
A Request Queue for an HTTPServer which pools threads.
ThreadPool objects must provide min, get(), put(obj), start() and stop(timeout) attributes.
grow(amount)
Spawn new worker threads (not above self.max).
162 Chapter 7. Reference Manual
CherryPy Documentation, Release 3.2.4
idle
Number of worker threads which are idle. Read-only.
shrink(amount)
Kill off worker threads (not below self.min).
start()
Start the pool of threads.
SSL
classcherrypy.wsgiserver.SSLAdapter(certificate, private_key, certificate_chain=None)
Base class for SSL driver library adapters.
Required methods:
" wrap(sock) -> (wrapped socket, ssl environ dict)
" makefile(sock, mode= r , bufsize=DEFAULT_BUFFER_SIZE) -> socket file
object
WSGI
classcherrypy.wsgiserver.CherryPyWSGIServer(bind_addr, wsgi_app, numthreads=10,
server_name=None, max=-1, re-
quest_queue_size=5, timeout=10, shut-
down_timeout=5)
A subclass of HTTPServer which calls a WSGI application.
wsgi_version= (1, 0)
The version of WSGI to produce.
classcherrypy.wsgiserver.Gateway(req)
A base class to interface HTTPServer with other systems, such as WSGI.
respond()
Process the current request. Must be overridden in a subclass.
classcherrypy.wsgiserver.WSGIGateway(req)
A base class to interface HTTPServer with WSGI.
get_environ()
Return a new environ dict targeting the given wsgi.version
respond()
Process the current request.
start_response(status, headers, exc_info=None)
WSGI callable to begin the HTTP response.
write(chunk)
WSGI callable to write unbuffered data to the client.
This method is also used internally by start_response (to write data from the iterable returned by the WSGI
application).
classcherrypy.wsgiserver.WSGIGateway_10(req)
A Gateway class to interface HTTPServer with WSGI 1.0.x.
get_environ()
Return a new environ dict targeting the given wsgi.version
7.15. cherrypy.wsgiserver 163
CherryPy Documentation, Release 3.2.4
classcherrypy.wsgiserver.WSGIGateway_u0(req)
A Gateway class to interface HTTPServer with WSGI u.0.
WSGI u.0 is an experimental protocol, which uses unicode for keys and values in both Python 2 and Python 3.
get_environ()
Return a new environ dict targeting the given wsgi.version
classcherrypy.wsgiserver.WSGIPathInfoDispatcher(apps)
A WSGI dispatcher for dispatch based on the PATH_INFO.
apps: a dict or list of (path_prefix, app) pairs.
7.15.2 cherrypy.wsgiserver.ssl_builtin Builtin SSL
A library for integrating Python s builtinssllibrary with CherryPy.
The ssl module must be importable for SSL functionality.
To use this module, setCherryPyWSGIServer.ssl_adapterto an instance ofBuiltinSSLAdapter.
Classes
classcherrypy.wsgiserver.ssl_builtin.BuiltinSSLAdapter(certificate, private_key, certifi-
cate_chain=None)
A wrapper for integrating Python s builtin ssl module with CherryPy.
bind(sock)
Wrap and return the given socket.
certificate= None
The filename of the server SSL certificate.
get_environ(sock)
Create WSGI environ entries to be merged into each request.
private_key= None
The filename of the server s private key file.
wrap(sock)
Wrap and return the given socket, plus WSGI environ entries.
7.15.3 cherrypy.wsgiserver.ssl_pyopenssl pyOpenSSL
A library for integrating pyOpenSSL with CherryPy.
The OpenSSL module must be importable for SSL functionality. You can obtain it from here.
To use this module, set CherryPyWSGIServer.ssl_adapter to an instance of SSLAdapter. There are two ways to use
SSL:
Method One
" ssl_adapter.context: an instance of SSL.Context.
164 Chapter 7. Reference Manual
CherryPy Documentation, Release 3.2.4
If this is not None, it is assumed to be an SSL.Context instance, and will be passed to SSL.Connection on bind(). The
developer is responsible for forming a valid Context object. This approach is to be preferred for more flexibility, e.g.
if the cert and key are streams instead of files, or need decryption, or SSL.SSLv3_METHOD is desired instead of the
default SSL.SSLv23_METHOD, etc. Consult the pyOpenSSL documentation for complete options.
Method Two (shortcut) [ Pobierz całość w formacie PDF ] - zanotowane.pl
- doc.pisz.pl
- pdf.pisz.pl
- zambezia2013.opx.pl