Back to index

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

List of all members.

Public Member Functions

def __init__
def run
def processInput
def writePacket

Public Attributes

 server
 logger

Private Member Functions

def _forwardRequest
def _shutdown
def _ping
def _cping
def _processBody

Private Attributes

 _sock
 _addr
 _request

Detailed Description

A single Connection with the server. Requests are not multiplexed over the
same connection, so at any given time, the Connection is either
waiting for a request, or processing a single request.

Definition at line 594 of file ajp_base.py.


Constructor & Destructor Documentation

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

Definition at line 600 of file ajp_base.py.

00600 
00601     def __init__(self, sock, addr, server):
00602         self.server = server
00603         self._sock = sock
00604         self._addr = addr
00605 
00606         self._request = None
00607 
00608         self.logger = logging.getLogger(LoggerName)


Member Function Documentation

def MoinMoin.support.flup.server.ajp_base.Connection._cping (   self,
  pkt 
) [private]
Respond to a PING (CPING) packet.

Definition at line 718 of file ajp_base.py.

00718 
00719     def _cping(self, pkt):
00720         """Respond to a PING (CPING) packet."""
00721         self.logger.debug('Received PING, sending PONG')
00722         pkt = Packet()
00723         pkt.data = PKTTYPE_CPONG
00724         self.writePacket(pkt)

Here is the call graph for this function:

Here is the caller graph for this function:

Creates a Request object, fills it in from the packet, then runs it.

Definition at line 658 of file ajp_base.py.

00658 
00659     def _forwardRequest(self, pkt):
00660         """
00661         Creates a Request object, fills it in from the packet, then runs it.
00662         """
00663         assert self._request is None
00664 
00665         req = self.server.requestClass(self)
00666         i = ord(pkt.data[1])
00667         method = methodTable[i]
00668         if method is None:
00669             raise ValueError, 'bad method field'
00670         req.setMethod(method)
00671         value, pos = decodeString(pkt.data, 2)
00672         req.setProtocol(value)
00673         value, pos = decodeString(pkt.data, pos)
00674         req.setRequestURI(value)
00675         value, pos = decodeString(pkt.data, pos)
00676         req.setRemoteAddr(value)
00677         value, pos = decodeString(pkt.data, pos)
00678         req.setRemoteHost(value)
00679         value, pos = decodeString(pkt.data, pos)
00680         req.setServerName(value)
00681         value = struct.unpack('>H', pkt.data[pos:pos+2])[0]
00682         req.setServerPort(value)
00683         i = ord(pkt.data[pos+2])
00684         req.setIsSSL(i != 0)
00685 
00686         # Request headers.
00687         numHeaders = struct.unpack('>H', pkt.data[pos+3:pos+5])[0]
00688         pos += 5
00689         for i in range(numHeaders):
00690             name, value, pos = decodeRequestHeader(pkt.data, pos)
00691             req.addHeader(name, value)
00692 
00693         # Attributes.
00694         while True:
00695             name, value, pos = decodeAttribute(pkt.data, pos)
00696             if name is None:
00697                 break
00698             req.addAttribute(name, value)
00699 
00700         self._request = req
00701 
00702         # Read first body chunk, if needed.
00703         if req.input.bytesAvailForAdd():
00704             self.processInput()
00705 
00706         # Run Request.
00707         req.run()
00708 
00709         self._request = None

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.support.flup.server.ajp_base.Connection._ping (   self,
  pkt 
) [private]
I have no idea what this packet means.

Definition at line 714 of file ajp_base.py.

00714 
00715     def _ping(self, pkt):
00716         """I have no idea what this packet means."""
00717         self.logger.debug('Received ping')

Here is the caller graph for this function:

Handles a body chunk from the server by appending it to the
InputStream.

Definition at line 725 of file ajp_base.py.

00725 
00726     def _processBody(self, pkt):
00727         """
00728         Handles a body chunk from the server by appending it to the
00729         InputStream.
00730         """
00731         if pkt.length:
00732             length = struct.unpack('>H', pkt.data[:2])[0]
00733             self._request.input.addData(pkt.data[2:2+length])
00734         else:
00735             # Shouldn't really ever get here.
00736             self._request.input.addData('')

Here is the caller graph for this function:

Not sure what to do with this yet.

Definition at line 710 of file ajp_base.py.

00710 
00711     def _shutdown(self, pkt):
00712         """Not sure what to do with this yet."""
00713         self.logger.info('Received shutdown request from server')

Here is the caller graph for this function:

Wait for and process a single packet.

Definition at line 632 of file ajp_base.py.

00632 
00633     def processInput(self):
00634         """Wait for and process a single packet."""
00635         pkt = Packet()
00636         select.select([self._sock], [], [])
00637         pkt.read(self._sock)
00638 
00639         # Body chunks have no packet type code.
00640         if self._request is not None:
00641             self._processBody(pkt)
00642             return
00643 
00644         if not pkt.length:
00645             raise ProtocolError, 'unexpected empty packet'
00646 
00647         pkttype = pkt.data[0]
00648         if pkttype == PKTTYPE_FWD_REQ:
00649             self._forwardRequest(pkt)
00650         elif pkttype == PKTTYPE_SHUTDOWN:
00651             self._shutdown(pkt)
00652         elif pkttype == PKTTYPE_PING:
00653             self._ping(pkt)
00654         elif pkttype == PKTTYPE_CPING:
00655             self._cping(pkt)
00656         else:
00657             raise ProtocolError, 'unknown packet type'

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 609 of file ajp_base.py.

00609 
00610     def run(self):
00611         self.logger.debug('Connection starting up (%s:%d)',
00612                           self._addr[0], self._addr[1])
00613 
00614         # Main loop. Errors will cause the loop to be exited and
00615         # the socket to be closed.
00616         while True:
00617             try:
00618                 self.processInput()
00619             except ProtocolError, e:
00620                 self.logger.error("Protocol error '%s'", str(e))
00621                 break
00622             except (EOFError, KeyboardInterrupt):
00623                 break
00624             except:
00625                 self.logger.exception('Exception caught in Connection')
00626                 break
00627 
00628         self.logger.debug('Connection shutting down (%s:%d)',
00629                           self._addr[0], self._addr[1])
00630 
00631         self._sock.close()

Here is the call graph for this function:

Sends a Packet to the server.

Definition at line 737 of file ajp_base.py.

00737 
00738     def writePacket(self, pkt):
00739         """Sends a Packet to the server."""
00740         pkt.write(self._sock)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 603 of file ajp_base.py.

Definition at line 605 of file ajp_base.py.

Definition at line 602 of file ajp_base.py.

Definition at line 607 of file ajp_base.py.

Definition at line 601 of file ajp_base.py.


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