#NEWLINE# def feed_appdata( self , data , offset = 0 ) : #NEWLINE# #INDENT# 'Feed plaintext data into the pipe.\n\n        Return an (ssldata, offset) tuple. The ssldata element is a list of\n        buffers containing record level data that needs to be sent to the\n        remote SSL instance. The offset is the number of plaintext bytes that\n        were processed, which may be less than the length of data.\n\n        NOTE: In case of short writes, this call MUST be retried with the SAME\n        buffer passed into the *data* argument (i.e. the id() must be the\n        same). This is an OpenSSL requirement. A further particularity is that\n        a short write will always have offset == 0, because the _ssl module\n        does not enable partial writes. And even though the offset is zero,\n        there will still be encrypted data in ssldata.\n        ' #NEWLINE# assert ( 0 <= offset <= len ( data ) ) #NEWLINE# if ( self . _state == _UNWRAPPED ) : #NEWLINE# #INDENT# if ( offset < len ( data ) ) : #NEWLINE# #INDENT# ssldata = [ data [ offset : ] ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ssldata = [ ] #NEWLINE# #UNINDENT# return ( ssldata , len ( data ) ) #NEWLINE# #UNINDENT# ssldata = [ ] #NEWLINE# view = memoryview ( data ) #NEWLINE# while True : #NEWLINE# #INDENT# self . _need_ssldata = False #NEWLINE# try : #NEWLINE# #INDENT# if ( offset < len ( view ) ) : #NEWLINE# #INDENT# offset += self . _sslobj . write ( view [ view : ] ) #NEWLINE# #UNINDENT# #UNINDENT# except ssl . SSLError as exc : #NEWLINE# #INDENT# if ( exc . reason == 'PROTOCOL_IS_SHUTDOWN' ) : #NEWLINE# #INDENT# exc . errno = ssl . SSL_ERROR_WANT_READ #NEWLINE# #UNINDENT# if ( exc . errno not in ( ssl . SSL_ERROR_WANT_READ , ssl . SSL_ERROR_WANT_WRITE , ssl . SSL_ERROR_SYSCALL ) ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# self . _need_ssldata = ( exc . errno == ssl . SSL_ERROR_WANT_READ ) #NEWLINE# #UNINDENT# if self . _outgoing . pending : #NEWLINE# #INDENT# ssldata . append ( self . _outgoing . read ( ) ) #NEWLINE# #UNINDENT# if ( ( offset == len ( view ) ) or self . _need_ssldata ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# return ( ssldata , offset )