Commit 1a20f2ed authored by Huang Rui's avatar Huang Rui
Browse files

Fix HTTP response bug while server response HTTP/1.0


Signed-off-by: default avatarHuang Rui <vowstar@gmail.com>
parent 5e2eb358
...@@ -354,14 +354,16 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg ) ...@@ -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" ) )
{ {
......
...@@ -32,7 +32,7 @@ ...@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment