Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
http.server.HTTPServer Class Reference
Inheritance diagram for http.server.HTTPServer:
Inheritance graph
[legend]
Collaboration diagram for http.server.HTTPServer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def server_bind
def server_activate
def server_close
def fileno
def get_request
def shutdown_request
def close_request
def serve_forever
def shutdown
def handle_request
def handle_timeout
def verify_request
def process_request
def finish_request
def handle_error

Public Attributes

 server_name
 server_port
 socket
 server_address
 RequestHandlerClass

Static Public Attributes

int allow_reuse_address = 1
 address_family = socket.AF_INET
 socket_type = socket.SOCK_STREAM
int request_queue_size = 5
 timeout = None

Detailed Description

Definition at line 126 of file server.py.


Member Function Documentation

def socketserver.TCPServer.close_request (   self,
  request 
) [inherited]
Called to clean up an individual request.

Reimplemented from socketserver.BaseServer.

Reimplemented in socketserver.UDPServer.

Definition at line 464 of file socketserver.py.

00464 
00465     def close_request(self, request):
00466         """Called to clean up an individual request."""
00467         request.close()
00468 

Here is the caller graph for this function:

def socketserver.TCPServer.fileno (   self) [inherited]
Return socket file number.

Interface required by select().

Definition at line 438 of file socketserver.py.

00438 
00439     def fileno(self):
00440         """Return socket file number.
00441 
00442         Interface required by select().
00443 
00444         """
00445         return self.socket.fileno()

Here is the caller graph for this function:

def socketserver.BaseServer.finish_request (   self,
  request,
  client_address 
) [inherited]
Finish one request by instantiating RequestHandlerClass.

Definition at line 321 of file socketserver.py.

00321 
00322     def finish_request(self, request, client_address):
00323         """Finish one request by instantiating RequestHandlerClass."""
00324         self.RequestHandlerClass(request, client_address, self)

Here is the caller graph for this function:

def socketserver.TCPServer.get_request (   self) [inherited]
Get the request and client address from the socket.

May be overridden.

Reimplemented in socketserver.UDPServer, idlelib.rpc.RPCServer, test.test_imaplib.SecureTCPServer, and test.test_urllib2_localnet.LoopbackHttpServer.

Definition at line 446 of file socketserver.py.

00446 
00447     def get_request(self):
00448         """Get the request and client address from the socket.
00449 
00450         May be overridden.
00451 
00452         """
00453         return self.socket.accept()

Here is the caller graph for this function:

def socketserver.BaseServer.handle_error (   self,
  request,
  client_address 
) [inherited]
Handle an error gracefully.  May be overridden.

The default is to print a traceback and continue.

Reimplemented in idlelib.run.MyRPCServer, and idlelib.rpc.RPCServer.

Definition at line 333 of file socketserver.py.

00333 
00334     def handle_error(self, request, client_address):
00335         """Handle an error gracefully.  May be overridden.
00336 
00337         The default is to print a traceback and continue.
00338 
00339         """
00340         print('-'*40)
00341         print('Exception happened during processing of request from', end=' ')
00342         print(client_address)
00343         import traceback
00344         traceback.print_exc() # XXX But this goes to stderr!
00345         print('-'*40)
00346 

Here is the call graph for this function:

Here is the caller graph for this function:

def socketserver.BaseServer.handle_request (   self) [inherited]
Handle one request, possibly blocking.

Respects self.timeout.

Definition at line 253 of file socketserver.py.

00253 
00254     def handle_request(self):
00255         """Handle one request, possibly blocking.
00256 
00257         Respects self.timeout.
00258         """
00259         # Support people who used socket.settimeout() to escape
00260         # handle_request before self.timeout was available.
00261         timeout = self.socket.gettimeout()
00262         if timeout is None:
00263             timeout = self.timeout
00264         elif self.timeout is not None:
00265             timeout = min(timeout, self.timeout)
00266         fd_sets = select.select([self], [], [], timeout)
00267         if not fd_sets[0]:
00268             self.handle_timeout()
00269             return
00270         self._handle_request_noblock()

Here is the call graph for this function:

Here is the caller graph for this function:

def socketserver.BaseServer.handle_timeout (   self) [inherited]
Called if no new request arrives within self.timeout.

Overridden by ForkingMixIn.

Definition at line 289 of file socketserver.py.

00289 
00290     def handle_timeout(self):
00291         """Called if no new request arrives within self.timeout.
00292 
00293         Overridden by ForkingMixIn.
00294         """
00295         pass

Here is the caller graph for this function:

def socketserver.BaseServer.process_request (   self,
  request,
  client_address 
) [inherited]
Call finish_request.

Overridden by ForkingMixIn and ThreadingMixIn.

Definition at line 304 of file socketserver.py.

00304 
00305     def process_request(self, request, client_address):
00306         """Call finish_request.
00307 
00308         Overridden by ForkingMixIn and ThreadingMixIn.
00309 
00310         """
00311         self.finish_request(request, client_address)
00312         self.shutdown_request(request)

Here is the call graph for this function:

Here is the caller graph for this function:

def socketserver.BaseServer.serve_forever (   self,
  poll_interval = 0.5 
) [inherited]
Handle one request at a time until shutdown.

Polls for shutdown every poll_interval seconds. Ignores
self.timeout. If you need to do periodic tasks, do them in
another thread.

Definition at line 211 of file socketserver.py.

00211 
00212     def serve_forever(self, poll_interval=0.5):
00213         """Handle one request at a time until shutdown.
00214 
00215         Polls for shutdown every poll_interval seconds. Ignores
00216         self.timeout. If you need to do periodic tasks, do them in
00217         another thread.
00218         """
00219         self.__is_shut_down.clear()
00220         try:
00221             while not self.__shutdown_request:
00222                 # XXX: Consider using another file descriptor or
00223                 # connecting to the socket to wake this up instead of
00224                 # polling. Polling reduces our responsiveness to a
00225                 # shutdown request and wastes cpu at all other times.
00226                 r, w, e = select.select([self], [], [], poll_interval)
00227                 if self in r:
00228                     self._handle_request_noblock()
00229         finally:
00230             self.__shutdown_request = False
00231             self.__is_shut_down.set()

Here is the call graph for this function:

def socketserver.TCPServer.server_activate (   self) [inherited]
Called by constructor to activate the server.

May be overridden.

Reimplemented from socketserver.BaseServer.

Reimplemented in socketserver.UDPServer, and idlelib.rpc.RPCServer.

Definition at line 422 of file socketserver.py.

00422 
00423     def server_activate(self):
00424         """Called by constructor to activate the server.
00425 
00426         May be overridden.
00427 
00428         """
00429         self.socket.listen(self.request_queue_size)

Override server_bind to store the server name.

Reimplemented from socketserver.TCPServer.

Reimplemented in wsgiref.simple_server.WSGIServer, and test.test_wsgiref.MockServer.

Definition at line 130 of file server.py.

00130 
00131     def server_bind(self):
00132         """Override server_bind to store the server name."""
00133         socketserver.TCPServer.server_bind(self)
00134         host, port = self.socket.getsockname()[:2]
00135         self.server_name = socket.getfqdn(host)
00136         self.server_port = port
00137 

Here is the call graph for this function:

Here is the caller graph for this function:

def socketserver.TCPServer.server_close (   self) [inherited]
Called to clean-up the server.

May be overridden.

Reimplemented from socketserver.BaseServer.

Definition at line 430 of file socketserver.py.

00430 
00431     def server_close(self):
00432         """Called to clean-up the server.
00433 
00434         May be overridden.
00435 
00436         """
00437         self.socket.close()

Here is the caller graph for this function:

def socketserver.BaseServer.shutdown (   self) [inherited]
Stops the serve_forever loop.

Blocks until the loop has finished. This must be called while
serve_forever() is running in another thread, or it will
deadlock.

Definition at line 232 of file socketserver.py.

00232 
00233     def shutdown(self):
00234         """Stops the serve_forever loop.
00235 
00236         Blocks until the loop has finished. This must be called while
00237         serve_forever() is running in another thread, or it will
00238         deadlock.
00239         """
00240         self.__shutdown_request = True
00241         self.__is_shut_down.wait()

def socketserver.TCPServer.shutdown_request (   self,
  request 
) [inherited]
Called to shutdown and close an individual request.

Reimplemented from socketserver.BaseServer.

Reimplemented in socketserver.UDPServer.

Definition at line 454 of file socketserver.py.

00454 
00455     def shutdown_request(self, request):
00456         """Called to shutdown and close an individual request."""
00457         try:
00458             #explicitly shutdown.  socket.close() merely releases
00459             #the socket and waits for GC to perform the actual close.
00460             request.shutdown(socket.SHUT_WR)
00461         except socket.error:
00462             pass #some platforms may raise ENOTCONN here
00463         self.close_request(request)

Here is the call graph for this function:

Here is the caller graph for this function:

def socketserver.BaseServer.verify_request (   self,
  request,
  client_address 
) [inherited]
Verify the request.  May be overridden.

Return True if we should proceed with this request.

Definition at line 296 of file socketserver.py.

00296 
00297     def verify_request(self, request, client_address):
00298         """Verify the request.  May be overridden.
00299 
00300         Return True if we should proceed with this request.
00301 
00302         """
00303         return True

Here is the caller graph for this function:


Member Data Documentation

socketserver.TCPServer.address_family = socket.AF_INET [static, inherited]

Reimplemented in socketserver.UnixDatagramServer, and socketserver.UnixStreamServer.

Definition at line 394 of file socketserver.py.

Reimplemented from socketserver.TCPServer.

Definition at line 128 of file server.py.

Definition at line 398 of file socketserver.py.

Definition at line 199 of file socketserver.py.

Reimplemented from socketserver.BaseServer.

Definition at line 420 of file socketserver.py.

Reimplemented in test.test_wsgiref.MockServer.

Definition at line 134 of file server.py.

Reimplemented in test.test_wsgiref.MockServer.

Definition at line 135 of file server.py.

Definition at line 405 of file socketserver.py.

socketserver.TCPServer.socket_type = socket.SOCK_STREAM [static, inherited]

Reimplemented in socketserver.UDPServer.

Definition at line 396 of file socketserver.py.

socketserver.BaseServer.timeout = None [static, inherited]

Reimplemented in test.test_logging.LogRecordSocketReceiver.

Definition at line 194 of file socketserver.py.


The documentation for this class was generated from the following file: