예제 #1
0
파일: http.py 프로젝트: chris-statzer/ganos
 def __init__(self, request_handler, max_request=104857600, keep_alive=True,
                 ssl_options=None):
     """
     Initializes an HTTP server object.
     
     Args:
         request_handler: A callable that should accept a single parameter,
             that being an instance of the HTTPRequest class representing
             the current request.
         max_request: The maximum allowed length of an incoming HTTP request
             body, which is used for receiving HTTP POST data and uploaded
             files. Optional. Defaults to 10MB.
         keep_alive: If set to False, only one request will be allowed per
             connection. Optional.
         ssl_options: A dict of options for establishing SSL connections. If
             this is set, the server will be able to serve pages via HTTPS
             and not just HTTP. The keys and values provided should mimic
             the arguments taken by ssl.wrap_socket.
     """
     SSLServer.__init__(self, ssl_options=ssl_options)
     
     # Storage
     self.request_handler    = request_handler
     self.max_request        = max_request
     self.keep_alive         = keep_alive
예제 #2
0
파일: http.py 프로젝트: chris-statzer/ganos
 def listen(self, port=None, host='', backlog=1024):
     """
     Begins listening on the given host and port.
     
     Args:
         port: The port to listen on. Optional. If not specified, will be
             set to 80 for regular HTTP, or 443 if SSL options have been
             set.
         host: The hostname to listen on. Defaults to ''.
         backlog: The maximum number of queued connections. Defaults
             to 1024.
     """
     if not port:
         if self.ssl_options:
             port = 443
         else:
             port = 80
     
     SSLServer.listen(self, port, host, backlog)