mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-05-04 22:02:11 +00:00
Adapt ssl_server2 to test sending long messages
This commit is contained in:
parent
6b4f237f6a
commit
bd7ce63115
|
@ -69,10 +69,16 @@
|
||||||
#define DFL_MAX_VERSION -1
|
#define DFL_MAX_VERSION -1
|
||||||
#define DFL_AUTH_MODE SSL_VERIFY_OPTIONAL
|
#define DFL_AUTH_MODE SSL_VERIFY_OPTIONAL
|
||||||
|
|
||||||
|
#define LONG_RESPONSE "<p>blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah\r\n" \
|
||||||
|
"blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah\r\n" \
|
||||||
|
"blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah\r\n" \
|
||||||
|
"blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah-blah</p>\r\n"
|
||||||
|
|
||||||
|
/* Uncomment LONG_RESPONSE to test sending long paquets */
|
||||||
#define HTTP_RESPONSE \
|
#define HTTP_RESPONSE \
|
||||||
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \
|
"HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n" \
|
||||||
"<h2>PolarSSL Test Server</h2>\r\n" \
|
"<h2>PolarSSL Test Server</h2>\r\n" \
|
||||||
"<p>Successful connection using: %s</p>\r\n"
|
"<p>Successful connection using: %s</p>\r\n" // LONG_RESPONSE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* global options
|
* global options
|
||||||
|
@ -168,7 +174,7 @@ int main( int argc, char *argv[] )
|
||||||
#else
|
#else
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
int ret = 0, len;
|
int ret = 0, len, written;
|
||||||
int listen_fd;
|
int listen_fd;
|
||||||
int client_fd = -1;
|
int client_fd = -1;
|
||||||
unsigned char buf[1024];
|
unsigned char buf[1024];
|
||||||
|
@ -748,7 +754,7 @@ reset:
|
||||||
}
|
}
|
||||||
|
|
||||||
len = ret;
|
len = ret;
|
||||||
printf( " %d bytes read\n\n%s", len, (char *) buf );
|
printf( " %d bytes read\n\n%s\n", len, (char *) buf );
|
||||||
|
|
||||||
if( memcmp( buf, "SERVERQUIT", 10 ) == 0 )
|
if( memcmp( buf, "SERVERQUIT", 10 ) == 0 )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -767,7 +773,9 @@ reset:
|
||||||
len = sprintf( (char *) buf, HTTP_RESPONSE,
|
len = sprintf( (char *) buf, HTTP_RESPONSE,
|
||||||
ssl_get_ciphersuite( &ssl ) );
|
ssl_get_ciphersuite( &ssl ) );
|
||||||
|
|
||||||
while( ( ret = ssl_write( &ssl, buf, len ) ) <= 0 )
|
for( written = 0; written < len; written += ret )
|
||||||
|
{
|
||||||
|
while( ( ret = ssl_write( &ssl, buf + written, len - written ) ) <= 0 )
|
||||||
{
|
{
|
||||||
if( ret == POLARSSL_ERR_NET_CONN_RESET )
|
if( ret == POLARSSL_ERR_NET_CONN_RESET )
|
||||||
{
|
{
|
||||||
|
@ -781,9 +789,10 @@ reset:
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
len = ret;
|
buf[written] = '\0';
|
||||||
printf( " %d bytes written\n\n%s\n", len, (char *) buf );
|
printf( " %d bytes written\n\n%s\n", written, (char *) buf );
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
goto reset;
|
goto reset;
|
||||||
|
|
Loading…
Reference in a new issue