@@ -293,6 +293,7 @@ cdef class SSLProtocol:
293293 self ._ssl_read_buffer = None
294294 else :
295295 self ._app_protocol_is_buffer = False
296+ self ._app_protocol_data_received = app_protocol.data_received
296297 if self ._ssl_read_buffer is None :
297298 self ._ssl_read_buffer = PyByteArray_FromStringAndSize(
298299 NULL , SSL_READ_MAX_SIZE)
@@ -361,7 +362,7 @@ cdef class SSLProtocol:
361362 cdef get_buffer_impl(self , size_t n, char ** buf, size_t* buf_size):
362363 cdef Py_ssize_t want = min (< Py_ssize_t> n, SSL_READ_MAX_SIZE)
363364
364- if len (self ._plain_read_buffer) < want:
365+ if PyByteArray_GET_SIZE (self ._plain_read_buffer) < want:
365366 PyByteArray_Resize(self ._plain_read_buffer, want)
366367 if self ._ssl_read_buffer is not None :
367368 PyByteArray_Resize(self ._ssl_read_buffer, want)
@@ -371,7 +372,7 @@ cdef class SSLProtocol:
371372
372373 cdef buffer_updated_impl(self , size_t nbytes):
373374 mv = PyMemoryView_FromMemory(
374- self ._plain_read_buffer,
375+ PyByteArray_AS_STRING( self ._plain_read_buffer) ,
375376 nbytes,
376377 PyBUF_WRITE
377378 )
@@ -855,10 +856,11 @@ cdef class SSLProtocol:
855856 pass
856857
857858 if data is not None :
858- self ._app_protocol.data_received (b' ' .join(data))
859+ self ._app_protocol_data_received (b' ' .join(data))
859860 elif first_chunk is not None :
860- self ._app_protocol.data_received(first_chunk)
861- elif bytes_read == 0 :
861+ self ._app_protocol_data_received(first_chunk)
862+
863+ if bytes_read == 0 :
862864 # close_notify
863865 self ._call_eof_received()
864866 self ._start_shutdown()
0 commit comments