Back to index

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

List of all members.

Public Member Functions

def __init__
def read
def write

Public Attributes

 data
 length

Private Member Functions

def _recvall
def _sendall

Static Private Attributes

tuple _recvall = staticmethod(_recvall)
tuple _sendall = staticmethod(_sendall)

Detailed Description

An AJP message packet.

Definition at line 234 of file ajp_base.py.


Constructor & Destructor Documentation

Definition at line 236 of file ajp_base.py.

00236 
00237     def __init__(self):
00238         self.data = ''
00239         # Don't set this on write, it will be calculated automatically.
00240         self.length = 0


Member Function Documentation

def MoinMoin.support.flup.server.ajp_base.Packet._recvall (   sock,
  length 
) [private]
Attempts to receive length bytes from a socket, blocking if necessary.
(Socket may be blocking or non-blocking.)

Definition at line 241 of file ajp_base.py.

00241 
00242     def _recvall(sock, length):
00243         """
00244         Attempts to receive length bytes from a socket, blocking if necessary.
00245         (Socket may be blocking or non-blocking.)
00246         """
00247         dataList = []
00248         recvLen = 0
00249         while length:
00250             try:
00251                 data = sock.recv(length)
00252             except socket.error, e:
00253                 if e[0] == errno.EAGAIN:
00254                     select.select([sock], [], [])
00255                     continue
00256                 else:
00257                     raise
00258             if not data: # EOF
00259                 break
00260             dataList.append(data)
00261             dataLen = len(data)
00262             recvLen += dataLen
00263             length -= dataLen
        return ''.join(dataList), recvLen
def MoinMoin.support.flup.server.ajp_base.Packet._sendall (   sock,
  data 
) [private]
Writes data to a socket and does not return until all the data is sent.

Definition at line 290 of file ajp_base.py.

00290 
00291     def _sendall(sock, data):
00292         """
00293         Writes data to a socket and does not return until all the data is sent.
00294         """
00295         length = len(data)
00296         while length:
00297             try:
00298                 sent = sock.send(data)
00299             except socket.error, e:
00300                 if e[0] == errno.EAGAIN:
00301                     select.select([], [sock], [])
00302                     continue
00303                 else:
00304                     raise
00305             data = data[sent:]
            length -= sent
Attempt to read a packet from the server.

Definition at line 266 of file ajp_base.py.

00266 
00267     def read(self, sock):
00268         """Attempt to read a packet from the server."""
00269         try:
00270             header, length = self._recvall(sock, 4)
00271         except socket.error:
00272             # Treat any sort of socket errors as EOF (close Connection).
00273             raise EOFError
00274 
00275         if length < 4:
00276             raise EOFError
00277 
00278         if header[:2] != SERVER_PREFIX:
00279             raise ProtocolError, 'invalid header'
00280 
00281         self.length = struct.unpack('>H', header[2:4])[0]
00282         if self.length:
00283             try:
00284                 self.data, length = self._recvall(sock, self.length)
00285             except socket.error:
00286                 raise EOFError
00287 
00288             if length < self.length:
00289                 raise EOFError

Here is the caller graph for this function:

Send a packet to the server.

Definition at line 308 of file ajp_base.py.

00308 
00309     def write(self, sock):
00310         """Send a packet to the server."""
00311         self.length = len(self.data)
00312         self._sendall(sock, CONTAINER_PREFIX + struct.pack('>H', self.length))
00313         if self.length:
00314             self._sendall(sock, self.data)

Here is the caller graph for this function:


Member Data Documentation

tuple MoinMoin.support.flup.server.ajp_base.Packet._recvall = staticmethod(_recvall) [static, private]

Definition at line 264 of file ajp_base.py.

tuple MoinMoin.support.flup.server.ajp_base.Packet._sendall = staticmethod(_sendall) [static, private]

Definition at line 306 of file ajp_base.py.

Definition at line 237 of file ajp_base.py.

Definition at line 239 of file ajp_base.py.


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