@@ -740,7 +740,7 @@ int HTTPClient::sendRequest(const char * type, Stream * stream, size_t size)
740
740
return returnError (HTTPC_ERROR_SEND_HEADER_FAILED);
741
741
}
742
742
743
- int buff_size = HTTP_TCP_BUFFER_SIZE ;
743
+ int buff_size = HTTP_TCP_TX_BUFFER_SIZE ;
744
744
745
745
int len = size;
746
746
int bytesWritten = 0 ;
@@ -749,8 +749,8 @@ int HTTPClient::sendRequest(const char * type, Stream * stream, size_t size)
749
749
len = -1 ;
750
750
}
751
751
752
- // if possible create smaller buffer then HTTP_TCP_BUFFER_SIZE
753
- if ((len > 0 ) && (len < HTTP_TCP_BUFFER_SIZE )) {
752
+ // if possible create smaller buffer then HTTP_TCP_TX_BUFFER_SIZE
753
+ if ((len > 0 ) && (len < buff_size )) {
754
754
buff_size = len;
755
755
}
756
756
@@ -843,7 +843,7 @@ int HTTPClient::sendRequest(const char * type, Stream * stream, size_t size)
843
843
}
844
844
845
845
} else {
846
- log_d (" too less ram! need %d" , HTTP_TCP_BUFFER_SIZE );
846
+ log_d (" too less ram! need %d" , buff_size );
847
847
return returnError (HTTPC_ERROR_TOO_LESS_RAM);
848
848
}
849
849
@@ -933,7 +933,7 @@ int HTTPClient::writeToStream(Stream * stream)
933
933
// read size of chunk
934
934
len = (uint32_t ) strtol ((const char *) chunkHeader.c_str (), NULL , 16 );
935
935
size += len;
936
- log_d (" read chunk len: %d" , len);
936
+ log_v (" read chunk len: %d" , len);
937
937
938
938
// data left?
939
939
if (len > 0 ) {
@@ -1364,12 +1364,12 @@ int HTTPClient::handleHeaderResponse()
1364
1364
*/
1365
1365
int HTTPClient::writeToStreamDataBlock (Stream * stream, int size)
1366
1366
{
1367
- int buff_size = HTTP_TCP_BUFFER_SIZE ;
1367
+ int buff_size = HTTP_TCP_RX_BUFFER_SIZE ;
1368
1368
int len = size;
1369
1369
int bytesWritten = 0 ;
1370
1370
1371
- // if possible create smaller buffer then HTTP_TCP_BUFFER_SIZE
1372
- if ((len > 0 ) && (len < HTTP_TCP_BUFFER_SIZE )) {
1371
+ // if possible create smaller buffer then HTTP_TCP_RX_BUFFER_SIZE
1372
+ if ((len > 0 ) && (len < buff_size )) {
1373
1373
buff_size = len;
1374
1374
}
1375
1375
@@ -1381,7 +1381,10 @@ int HTTPClient::writeToStreamDataBlock(Stream * stream, int size)
1381
1381
while (connected () && (len > 0 || len == -1 )) {
1382
1382
1383
1383
// get available data size
1384
- size_t sizeAvailable = _client->available ();
1384
+ size_t sizeAvailable = buff_size;
1385
+ if (len < 0 ){
1386
+ sizeAvailable = _client->available ();
1387
+ }
1385
1388
1386
1389
if (sizeAvailable) {
1387
1390
@@ -1457,15 +1460,15 @@ int HTTPClient::writeToStreamDataBlock(Stream * stream, int size)
1457
1460
1458
1461
free (buff);
1459
1462
1460
- log_d (" connection closed or file end (written: %d)." , bytesWritten);
1463
+ log_v (" connection closed or file end (written: %d)." , bytesWritten);
1461
1464
1462
1465
if ((size > 0 ) && (size != bytesWritten)) {
1463
1466
log_d (" bytesWritten %d and size %d mismatch!." , bytesWritten, size);
1464
1467
return HTTPC_ERROR_STREAM_WRITE;
1465
1468
}
1466
1469
1467
1470
} else {
1468
- log_w (" too less ram! need %d" , HTTP_TCP_BUFFER_SIZE );
1471
+ log_w (" too less ram! need %d" , buff_size );
1469
1472
return HTTPC_ERROR_TOO_LESS_RAM;
1470
1473
}
1471
1474
0 commit comments