Package core :: Module http :: Class HttpServer
[hide private]
[frames] | no frames]

Class HttpServer

source code

            object --+    
                     |    
tcp_support.TCPSupport --+
                         |
            object --+   |
                     |   |
ssl_support.SSLSupport --+
                         |
                object --+
                         |
                        HttpServer

An HTTP and websockets server

Instance Methods [hide private]
 
__init__(self, **kwargs) source code
 
request_handler(self, handler)
Set the HTTP request handler for the server.
source code
 
websocket_handler(self, handler)
Set the websocket handler for the server.
source code
 
listen(self, port, host=None)
Instruct the server to listen for incoming connections.
source code
 
client_auth_required(self, val)
Client authentication is an extra level of security in SSL, and requires clients to provide client certificates.
source code
 
close(self, handler=None)
Close the server.
source code
 
_to_java_server(self)
private
source code

Inherited from tcp_support.TCPSupport: set_receive_buffer_size, set_reuse_address, set_send_buffer_size, set_so_linger, set_tcp_keep_alive, set_traffic_class

Inherited from ssl_support.SSLSupport: set_key_store_password, set_key_store_path, set_ssl, set_trust_store_password, set_trust_store_path

Class Variables [hide private]

Inherited from tcp_support.TCPSupport: receive_buffer_size, reuse_address, send_buffer_size, so_linger, tcp_keep_alive, traffic_class

Inherited from ssl_support.SSLSupport: key_store_password, key_store_path, ssl, trust_store_password, trust_store_path

Method Details [hide private]

__init__(self, **kwargs)
(Constructor)

source code 
Overrides: object.__init__
(inherited documentation)

request_handler(self, handler)

source code 

Set the HTTP request handler for the server. As HTTP requests arrive on the server a new HttpServerRequest instance will be created and passed to the handler.

Keyword arguments:

Parameters:
  • handler - the function used to handle the request.
Returns:
self

websocket_handler(self, handler)

source code 

Set the websocket handler for the server. As websocket requests arrive on the server a new ServerWebSocket instance will be created and passed to the handler.

Keyword arguments:

Parameters:
  • handler - the function used to handle the request.

listen(self, port, host=None)

source code 

Instruct the server to listen for incoming connections. If host is None listens on all.

Keyword arguments:

Parameters:
  • port - The port to listen on.
  • host - The host name or ip address to listen on. (default None)

client_auth_required(self, val)

source code 

Client authentication is an extra level of security in SSL, and requires clients to provide client certificates. Those certificates must be added to the server trust store.

Keyword arguments:

Parameters:
  • val - If true then the server will request client authentication from any connecting clients, if they do not authenticate then they will not make a connection.

close(self, handler=None)

source code 

Close the server. Any open HTTP connections will be closed. This can be used as a decorator.

Keyword arguments:

Parameters:
  • handler - a handler that is called when the connection is closed. The handler is wrapped in a ClosedHandler.