Fix HTTP response bug while server response HTTP/1.0

Signed-off-by: Huang Rui <vowstar@gmail.com>
This commit is contained in:
Huang Rui 2016-01-26 16:06:11 +08:00
parent 5e2eb3588c
commit 1a20f2eda8
2 changed files with 6 additions and 4 deletions

View File

@ -354,14 +354,16 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
else if ( req->buffer[0] != '\0' ) else if ( req->buffer[0] != '\0' )
{ {
/* FIXME: make sure this is not a partial response, using the Content-Length header. */ /* FIXME: make sure this is not a partial response, using the Content-Length header. */
const char * version = "HTTP/1.1 "; const char * version_1_0 = "HTTP/1.0 ";
if ( os_strncmp( req->buffer, version, strlen( version ) ) != 0 ) const char * version_1_1 = "HTTP/1.1 ";
if (( os_strncmp( req->buffer, version_1_0, strlen( version_1_0 ) ) != 0 ) &&
( os_strncmp( req->buffer, version_1_1, strlen( version_1_1 ) ) != 0 ))
{ {
HTTPCLIENT_DEBUG( "Invalid version in %s\n", req->buffer ); HTTPCLIENT_DEBUG( "Invalid version in %s\n", req->buffer );
} }
else else
{ {
http_status = atoi( req->buffer + strlen( version ) ); http_status = atoi( req->buffer + strlen( version_1_0 ) );
body = (char *) os_strstr( req->buffer, "\r\n\r\n" ) + 4; body = (char *) os_strstr( req->buffer, "\r\n\r\n" ) + 4;
if ( os_strstr( req->buffer, "Transfer-Encoding: chunked" ) ) if ( os_strstr( req->buffer, "Transfer-Encoding: chunked" ) )
{ {

View File

@ -32,7 +32,7 @@
/* /*
* Size of http responses that will cause an error. * Size of http responses that will cause an error.
*/ */
#define BUFFER_SIZE_MAX (1024) #define BUFFER_SIZE_MAX (0x2000)
/* /*
* Timeout of http request. * Timeout of http request.