Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Attributes
MoinMoin.support.flup.server.scgi_base.Connection Class Reference

List of all members.

Public Member Functions

def __init__
def run
def processInput

Public Attributes

 server
 logger

Private Attributes

 _sock
 _addr

Detailed Description

Represents a single client (web server) connection. A single request
is handled, after which the socket is closed.

Definition at line 200 of file scgi_base.py.


Constructor & Destructor Documentation

def MoinMoin.support.flup.server.scgi_base.Connection.__init__ (   self,
  sock,
  addr,
  server 
)

Definition at line 205 of file scgi_base.py.

00205 
00206     def __init__(self, sock, addr, server):
00207         self._sock = sock
00208         self._addr = addr
00209         self.server = server
00210 
00211         self.logger = logging.getLogger(LoggerName)


Member Function Documentation

Definition at line 233 of file scgi_base.py.

00233 
00234     def processInput(self):
00235         # Read headers
00236         headers = readNetstring(self._sock)
00237         headers = headers.split('\x00')[:-1]
00238         if len(headers) % 2 != 0:
00239             raise ProtocolError, 'invalid headers'
00240         environ = {}
00241         for i in range(len(headers) / 2):
00242             environ[headers[2*i]] = headers[2*i+1]
00243 
00244         clen = environ.get('CONTENT_LENGTH')
00245         if clen is None:
00246             raise ProtocolError, 'missing CONTENT_LENGTH'
00247         try:
00248             clen = int(clen)
00249             if clen < 0:
00250                 raise ValueError
00251         except ValueError:
00252             raise ProtocolError, 'invalid CONTENT_LENGTH'
00253 
00254         self._sock.setblocking(1)
00255         if clen:
00256             input = self._sock.makefile('r')
00257         else:
00258             # Empty input.
00259             input = StringIO.StringIO()
00260 
00261         # stdout
00262         output = self._sock.makefile('w')
00263 
00264         # Allocate Request
00265         req = Request(self, environ, input, output)
00266 
00267         # Run it.
00268         req.run()
00269 
00270         output.close()
00271         input.close()

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 212 of file scgi_base.py.

00212 
00213     def run(self):
00214         if len(self._addr) == 2:
00215             self.logger.debug('Connection starting up (%s:%d)',
00216                               self._addr[0], self._addr[1])
00217 
00218         try:
00219             self.processInput()
00220         except (EOFError, KeyboardInterrupt):
00221             pass
00222         except ProtocolError, e:
00223             self.logger.error("Protocol error '%s'", str(e))
00224         except:
00225             self.logger.exception('Exception caught in Connection')
00226 
00227         if len(self._addr) == 2:
00228             self.logger.debug('Connection shutting down (%s:%d)',
00229                               self._addr[0], self._addr[1])
00230 
00231         # All done!
00232         self._sock.close()

Here is the call graph for this function:


Member Data Documentation

Definition at line 207 of file scgi_base.py.

Definition at line 206 of file scgi_base.py.

Definition at line 210 of file scgi_base.py.

Definition at line 208 of file scgi_base.py.


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