Skip to content

HTTPClient writeToStream method reporting Stream write error as too few bytes written due to bug #9997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
s60sc opened this issue Jul 8, 2024 · 1 comment · Fixed by #9998
Closed
1 task done
Labels
Status: Awaiting triage Issue is waiting for triage

Comments

@s60sc
Copy link

s60sc commented Jul 8, 2024

Board

ESP32 Dev Module

Device Description

plain module on breadboard

Hardware Configuration

No

Version

latest master (checkout manually)

IDE Name

Arduino IDE

Operating System

Windows 10

Flash frequency

not specific

PSRAM enabled

yes

Upload speed

not specific

Description

Line 1388 in HTTPClient.cpp is:
len -= readBytes;
It should be:
len -= bytesRead;

as bytesRead can be less than readBytes

Sketch

n/a

Debug Message

Original:
[###### DBG @ HTTPClient.cpp:1307] len 38524, buff_size 4096
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 4096
[###### DBG @ HTTPClient.cpp:1393] left 34428
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 2759
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 2759, bytesWritten 6855
[###### DBG @ HTTPClient.cpp:1393] left 30332
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 0
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 0, bytesWritten 6855
[###### DBG @ HTTPClient.cpp:1393] left 26236
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 0
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 0, bytesWritten 6855
[###### DBG @ HTTPClient.cpp:1393] left 22140
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 10951
[###### DBG @ HTTPClient.cpp:1393] left 18044
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 15047
[###### DBG @ HTTPClient.cpp:1393] left 13948
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 19143
[###### DBG @ HTTPClient.cpp:1393] left 9852
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 23239
[###### DBG @ HTTPClient.cpp:1393] left 5756
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 3183
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 3183, bytesWritten 26422
[###### DBG @ HTTPClient.cpp:1393] left 1660
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 1660, bytesRead 1660
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 1660, bytesWritten 28082
[###### DBG @ HTTPClient.cpp:1393] left 0
[###### DBG @ HTTPClient.cpp:1405] bytesWritten 28082 and size 38524 mismatch!.
[###### DBG @ HTTPClient.cpp:1424] error(-10): Stream write error

After fix:
[###### DBG @ HTTPClient.cpp:1307] len 38524, buff_size 4096
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 4096
[###### DBG @ HTTPClient.cpp:1394] left 34428
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 8192
[###### DBG @ HTTPClient.cpp:1394] left 30332
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 34
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 34, bytesWritten 8226
[###### DBG @ HTTPClient.cpp:1394] left 30298
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 0
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 0, bytesWritten 8226
[###### DBG @ HTTPClient.cpp:1394] left 30298
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 12322
[###### DBG @ HTTPClient.cpp:1394] left 26202
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 16418
[###### DBG @ HTTPClient.cpp:1394] left 22106
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 20514
[###### DBG @ HTTPClient.cpp:1394] left 18010
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 24610
[###### DBG @ HTTPClient.cpp:1394] left 13914
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 28706
[###### DBG @ HTTPClient.cpp:1394] left 9818
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 32802
[###### DBG @ HTTPClient.cpp:1394] left 5722
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 4096, bytesRead 4096
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 4096, bytesWritten 36898
[###### DBG @ HTTPClient.cpp:1394] left 1626
[###### DBG @ HTTPClient.cpp:1330] sizeAvailable 4096, readBytes 4096
[###### DBG @ HTTPClient.cpp:1348] readBytes 1626, bytesRead 1626
[###### DBG @ HTTPClient.cpp:1352] bytesWrite 1626, bytesWritten 38524
[###### DBG @ HTTPClient.cpp:1394] left 0
[###### DBG @ HTTPClient.cpp:1403] connection closed or file end (written: 38524).
[###### DBG @ HTTPClient.cpp:1414] bytesWritten 38524

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@me-no-dev
Copy link
Member

Nice catch! Will be fixed here: #9998

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants