@@ -33,7 +33,7 @@ extern "C" {
3333
3434#define HTTP_CLIENT_AUTHB_SIZE 128
3535
36- #define HTTP_CLIENT_CHUNK_SIZE 1024
36+ #define HTTP_CLIENT_CHUNK_SIZE 1025
3737#define HTTP_CLIENT_SEND_BUF_SIZE 1024
3838
3939#define HTTP_CLIENT_MAX_HOST_LEN 64
@@ -351,8 +351,7 @@ static int _http_client_recv(HTTPClient *client, char *buf, int min_len, int max
351351 IOT_FUNC_EXIT_RC (rc );
352352 }
353353
354- // IOT_FUNC_EXIT_RC(rc);
355- IOT_FUNC_EXIT_RC (QCLOUD_RET_SUCCESS );
354+ IOT_FUNC_EXIT_RC (rc );
356355}
357356
358357static int _http_client_retrieve_content (HTTPClient * client , char * data , int len , uint32_t timeout_ms ,
@@ -392,7 +391,7 @@ static int _http_client_retrieve_content(HTTPClient *client, char *data, int len
392391 if (rc != QCLOUD_RET_SUCCESS ) {
393392 IOT_FUNC_EXIT_RC (rc );
394393 }
395- if (0 = = left_ms (& timer )) {
394+ if (0 > = left_ms (& timer )) {
396395 Log_e ("HTTP read timeout!" );
397396 IOT_FUNC_EXIT_RC (QCLOUD_ERR_HTTP_TIMEOUT );
398397 }
@@ -431,7 +430,8 @@ static int _http_client_retrieve_content(HTTPClient *client, char *data, int len
431430 rc = _http_client_recv (client , data + len , 0 , HTTP_CLIENT_CHUNK_SIZE - len - 1 , & new_trf_len ,
432431 left_ms (& timer ), client_data );
433432 len += new_trf_len ;
434- if (rc != QCLOUD_RET_SUCCESS ) {
433+ if ((rc != QCLOUD_RET_SUCCESS ) || (0 >= left_ms (& timer ))) {
434+ Log_w ("_http_client_recv ret: %d, left_time: %d" , rc , left_ms (& timer ));
435435 IOT_FUNC_EXIT_RC (rc );
436436 } else {
437437 continue ;
@@ -495,9 +495,10 @@ static int _http_client_retrieve_content(HTTPClient *client, char *data, int len
495495 max_len = HTTP_CLIENT_MIN (max_len , readLen );
496496 rc = _http_client_recv (client , data , 1 , max_len , & len , left_ms (& timer ), client_data );
497497 if (rc != QCLOUD_RET_SUCCESS ) {
498+ Log_w ("_http_client_recv ret: %d, left_time: %d" , rc , left_ms (& timer ));
498499 IOT_FUNC_EXIT_RC (rc );
499500 }
500- if (left_ms (& timer ) = = 0 ) {
501+ if (left_ms (& timer ) < = 0 ) {
501502 Log_e ("HTTP read timeout!" );
502503 IOT_FUNC_EXIT_RC (QCLOUD_ERR_HTTP_TIMEOUT );
503504 }
@@ -510,7 +511,8 @@ static int _http_client_retrieve_content(HTTPClient *client, char *data, int len
510511 /* Read missing chars to find end of chunk */
511512 rc = _http_client_recv (client , data + len , 2 - len , HTTP_CLIENT_CHUNK_SIZE - len - 1 , & new_trf_len ,
512513 left_ms (& timer ), client_data );
513- if ((rc != QCLOUD_RET_SUCCESS ) || (0 == left_ms (& timer ))) {
514+ if ((rc != QCLOUD_RET_SUCCESS ) || (0 >= left_ms (& timer ))) {
515+ Log_w ("_http_client_recv ret: %d, left_time: %d" , rc , left_ms (& timer ));
514516 IOT_FUNC_EXIT_RC (rc );
515517 }
516518 len += new_trf_len ;
0 commit comments