From 8df90735eb6d06cb3f31fabc2f42a7cc8843d208 Mon Sep 17 00:00:00 2001 From: toddouska Date: Fri, 27 Jan 2012 11:55:23 -0800 Subject: [PATCH] allow echoserver to accept 1 byte G then rest of GET for browsers with CBC hack --- examples/echoserver/echoserver.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index 11f4ccd81..a5882e767 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -135,6 +135,8 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args) char command[1024]; int echoSz = 0; int clientfd; + int firstRead = 1; + int gotFirstG = 0; #ifndef CYASSL_DTLS SOCKADDR_IN_T client; @@ -165,6 +167,18 @@ THREAD_RETURN CYASSL_THREAD echoserver_test(void* args) #endif while ( (echoSz = CyaSSL_read(ssl, command, sizeof(command))) > 0) { + + if (firstRead == 1) { + firstRead = 0; /* browser may send 1 byte 'G' to start */ + if (echoSz == 1 && command[0] == 'G') { + gotFirstG = 1; + continue; + } + } + else if (gotFirstG == 1 && strncmp(command, "ET /", 4) == 0) { + strncpy(command, "GET", 4); + /* fall through to normal GET */ + } if ( strncmp(command, "quit", 4) == 0) { printf("client sent quit command: shutting down!\n");