Please help unable to retrieve partial data

I need to retrieve the first 2048 bytes of data from a record that is too big for memory.
I’ve traced the problem to “mbedtls_ssl_fetch_input” which fails here:
if( nb_want > in_buf_len - (size_t)( ssl->in_hdr - ssl->in_buf ) )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( “requesting more data than fits” ) );
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
}
I’ve searched and searched and I can’t find a configuration to prevent mbedtls from trying to read the entire record
I’m using bare metal.

I’m replying to myself:
#define MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH in config.h solves this problem