Back to index

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

List of all members.

Public Member Functions

def __init__
def read
def write

Public Attributes

 version
 type
 requestId
 contentLength
 paddingLength
 contentData

Private Member Functions

def _recvall
def _sendall

Static Private Attributes

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

Detailed Description

A FastCGI Record.

Used for encoding/decoding records.

Definition at line 427 of file fcgi_base.py.


Constructor & Destructor Documentation

Definition at line 433 of file fcgi_base.py.

00433 
00434     def __init__(self, type=FCGI_UNKNOWN_TYPE, requestId=FCGI_NULL_REQUEST_ID):
00435         self.version = FCGI_VERSION_1
00436         self.type = type
00437         self.requestId = requestId
00438         self.contentLength = 0
00439         self.paddingLength = 0
00440         self.contentData = ''


Member Function Documentation

def MoinMoin.support.flup.server.fcgi_base.Record._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 441 of file fcgi_base.py.

00441 
00442     def _recvall(sock, length):
00443         """
00444         Attempts to receive length bytes from a socket, blocking if necessary.
00445         (Socket may be blocking or non-blocking.)
00446         """
00447         dataList = []
00448         recvLen = 0
00449         while length:
00450             try:
00451                 data = sock.recv(length)
00452             except socket.error, e:
00453                 if e[0] == errno.EAGAIN:
00454                     select.select([sock], [], [])
00455                     continue
00456                 else:
00457                     raise
00458             if not data: # EOF
00459                 break
00460             dataList.append(data)
00461             dataLen = len(data)
00462             recvLen += dataLen
00463             length -= dataLen
        return ''.join(dataList), recvLen
def MoinMoin.support.flup.server.fcgi_base.Record._sendall (   sock,
  data 
) [private]
Writes data to a socket and does not return until all the data is sent.

Definition at line 500 of file fcgi_base.py.

00500 
00501     def _sendall(sock, data):
00502         """
00503         Writes data to a socket and does not return until all the data is sent.
00504         """
00505         length = len(data)
00506         while length:
00507             try:
00508                 sent = sock.send(data)
00509             except socket.error, e:
00510                 if e[0] == errno.EAGAIN:
00511                     select.select([], [sock], [])
00512                     continue
00513                 else:
00514                     raise
00515             data = data[sent:]
            length -= sent
Read and decode a Record from a socket.

Definition at line 466 of file fcgi_base.py.

00466 
00467     def read(self, sock):
00468         """Read and decode a Record from a socket."""
00469         try:
00470             header, length = self._recvall(sock, FCGI_HEADER_LEN)
00471         except:
00472             raise EOFError
00473 
00474         if length < FCGI_HEADER_LEN:
00475             raise EOFError
00476         
00477         self.version, self.type, self.requestId, self.contentLength, \
00478                       self.paddingLength = struct.unpack(FCGI_Header, header)
00479 
00480         if __debug__: _debug(9, 'read: fd = %d, type = %d, requestId = %d, '
00481                              'contentLength = %d' %
00482                              (sock.fileno(), self.type, self.requestId,
00483                               self.contentLength))
00484         
00485         if self.contentLength:
00486             try:
00487                 self.contentData, length = self._recvall(sock,
00488                                                          self.contentLength)
00489             except:
00490                 raise EOFError
00491 
00492             if length < self.contentLength:
00493                 raise EOFError
00494 
00495         if self.paddingLength:
00496             try:
00497                 self._recvall(sock, self.paddingLength)
00498             except:
00499                 raise EOFError

Here is the call graph for this function:

Here is the caller graph for this function:

Encode and write a Record to a socket.

Definition at line 518 of file fcgi_base.py.

00518 
00519     def write(self, sock):
00520         """Encode and write a Record to a socket."""
00521         self.paddingLength = -self.contentLength & 7
00522 
00523         if __debug__: _debug(9, 'write: fd = %d, type = %d, requestId = %d, '
00524                              'contentLength = %d' %
00525                              (sock.fileno(), self.type, self.requestId,
00526                               self.contentLength))
00527 
00528         header = struct.pack(FCGI_Header, self.version, self.type,
00529                              self.requestId, self.contentLength,
00530                              self.paddingLength)
00531         self._sendall(sock, header)
00532         if self.contentLength:
00533             self._sendall(sock, self.contentData)
00534         if self.paddingLength:
00535             self._sendall(sock, '\x00'*self.paddingLength)
            

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

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

Definition at line 464 of file fcgi_base.py.

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

Definition at line 516 of file fcgi_base.py.

Definition at line 439 of file fcgi_base.py.

Definition at line 437 of file fcgi_base.py.

Definition at line 438 of file fcgi_base.py.

Definition at line 436 of file fcgi_base.py.

Definition at line 435 of file fcgi_base.py.

Definition at line 434 of file fcgi_base.py.


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