(self, amt=None)
return ret
Reads up to amt bytes from the SSL connection.
Reads up to amt bytes from the SSL connection.
Reads up to amt bytes from the SSL connection .
def read(self, amt=None):
        """
        Reads up to amt bytes from the SSL connection.
        """
        self._check_closed()
        # Initially, the buffer size is the default buffer size.
        # Unfortunately, pending() does not return meaningful data until
        # recv() is called, so we only adjust the buffer size after the
        # first read
        buffer_size = self._buffer_size

        # Read only the specified amount of data
        while amt is None or len(self._buffer) < amt:
            # if amt is None (read till the end), fills in self._buffer
            if amt is not None:
                buffer_size = min(amt - len(self._buffer), buffer_size)

            try:
                data = self._connection.recv(buffer_size)
 
                self._buffer = self._buffer + data

                # More bytes to read?
                pending = self._connection.pending()
                if pending == 0:
                    # we're done here
                    break
            except SSL.ZeroReturnError:
                # Nothing more to be read
                break
            except SSL.SysCallError, e:
                print "SSL exception", e.args
                break
            except SSL.WantWriteError:
                self._poll(select.POLLOUT, 'read')
            except SSL.WantReadError:
                self._poll(select.POLLIN, 'read')

        if amt:
            ret = self._buffer[:amt]
            self._buffer = self._buffer[amt:]
        else:
            ret = self._buffer
            self._buffer = ""

        self._pos = self._pos + len(ret)
        return ret
def read ( self , amt = None ) : self . _check_closed ( ) # Initially, the buffer size is the default buffer size. # Unfortunately, pending() does not return meaningful data until # recv() is called, so we only adjust the buffer size after the # first read buffer_size = self . _buffer_size # Read only the specified amount of data while amt is None or len ( self . _buffer ) < amt : # if amt is None (read till the end), fills in self._buffer if amt is not None : buffer_size = min ( amt - len ( self . _buffer ) , buffer_size ) try : data = self . _connection . recv ( buffer_size ) self . _buffer = self . _buffer + data # More bytes to read? pending = self . _connection . pending ( ) if pending == 0 : # we're done here break except SSL . ZeroReturnError : # Nothing more to be read break except SSL . SysCallError , e : print "SSL exception" , e . args break except SSL . WantWriteError : self . _poll ( select . POLLOUT , 'read' ) except SSL . WantReadError : self . _poll ( select . POLLIN , 'read' ) if amt : ret = self . _buffer [ : amt ] self . _buffer = self . _buffer [ amt : ] else : ret = self . _buffer self . _buffer = "" self . _pos = self . _pos + len ( ret ) return ret