Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes
MoinMoin.support.flup.client.fcgi_app.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 149 of file fcgi_app.py.


Constructor & Destructor Documentation

Definition at line 155 of file fcgi_app.py.

00155 
00156     def __init__(self, type=FCGI_UNKNOWN_TYPE, requestId=FCGI_NULL_REQUEST_ID):
00157         self.version = FCGI_VERSION_1
00158         self.type = type
00159         self.requestId = requestId
00160         self.contentLength = 0
00161         self.paddingLength = 0
00162         self.contentData = ''


Member Function Documentation

def MoinMoin.support.flup.client.fcgi_app.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 163 of file fcgi_app.py.

00163 
00164     def _recvall(sock, length):
00165         """
00166         Attempts to receive length bytes from a socket, blocking if necessary.
00167         (Socket may be blocking or non-blocking.)
00168         """
00169         dataList = []
00170         recvLen = 0
00171         while length:
00172             try:
00173                 data = sock.recv(length)
00174             except socket.error, e:
00175                 if e[0] == errno.EAGAIN:
00176                     select.select([sock], [], [])
00177                     continue
00178                 else:
00179                     raise
00180             if not data: # EOF
00181                 break
00182             dataList.append(data)
00183             dataLen = len(data)
00184             recvLen += dataLen
00185             length -= dataLen
        return ''.join(dataList), recvLen
def MoinMoin.support.flup.client.fcgi_app.Record._sendall (   sock,
  data 
) [private]
Writes data to a socket and does not return until all the data is sent.

Definition at line 222 of file fcgi_app.py.

00222 
00223     def _sendall(sock, data):
00224         """
00225         Writes data to a socket and does not return until all the data is sent.
00226         """
00227         length = len(data)
00228         while length:
00229             try:
00230                 sent = sock.send(data)
00231             except socket.error, e:
00232                 if e[0] == errno.EAGAIN:
00233                     select.select([], [sock], [])
00234                     continue
00235                 else:
00236                     raise
00237             data = data[sent:]
            length -= sent
Read and decode a Record from a socket.

Definition at line 188 of file fcgi_app.py.

00188 
00189     def read(self, sock):
00190         """Read and decode a Record from a socket."""
00191         try:
00192             header, length = self._recvall(sock, FCGI_HEADER_LEN)
00193         except:
00194             raise EOFError
00195 
00196         if length < FCGI_HEADER_LEN:
00197             raise EOFError
00198         
00199         self.version, self.type, self.requestId, self.contentLength, \
00200                       self.paddingLength = struct.unpack(FCGI_Header, header)
00201 
00202         if __debug__: _debug(9, 'read: fd = %d, type = %d, requestId = %d, '
00203                              'contentLength = %d' %
00204                              (sock.fileno(), self.type, self.requestId,
00205                               self.contentLength))
00206         
00207         if self.contentLength:
00208             try:
00209                 self.contentData, length = self._recvall(sock,
00210                                                          self.contentLength)
00211             except:
00212                 raise EOFError
00213 
00214             if length < self.contentLength:
00215                 raise EOFError
00216 
00217         if self.paddingLength:
00218             try:
00219                 self._recvall(sock, self.paddingLength)
00220             except:
00221                 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 240 of file fcgi_app.py.

00240 
00241     def write(self, sock):
00242         """Encode and write a Record to a socket."""
00243         self.paddingLength = -self.contentLength & 7
00244 
00245         if __debug__: _debug(9, 'write: fd = %d, type = %d, requestId = %d, '
00246                              'contentLength = %d' %
00247                              (sock.fileno(), self.type, self.requestId,
00248                               self.contentLength))
00249 
00250         header = struct.pack(FCGI_Header, self.version, self.type,
00251                              self.requestId, self.contentLength,
00252                              self.paddingLength)
00253         self._sendall(sock, header)
00254         if self.contentLength:
00255             self._sendall(sock, self.contentData)
00256         if self.paddingLength:
00257             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.client.fcgi_app.Record._recvall = staticmethod(_recvall) [static, private]

Definition at line 186 of file fcgi_app.py.

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

Definition at line 238 of file fcgi_app.py.

Definition at line 161 of file fcgi_app.py.

Definition at line 159 of file fcgi_app.py.

Definition at line 160 of file fcgi_app.py.

Definition at line 158 of file fcgi_app.py.

Definition at line 157 of file fcgi_app.py.

Definition at line 156 of file fcgi_app.py.


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