-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Modify to "String HTTPClient::getString(size_t size)" #10375
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
Comments
|
Please test with Arduino Core 3.2.0-rc2 if the behaviour is still there. |
@Jason2866: Sadly the " {I am using "https://github.com/espressif/arduino-esp32/tree/3.2.0-RC2" as at 16Mar25.) The below sketch demonstrates this:
|
Closing since issue cant not be reproduced with Arduino Core 3.2.0. Using the provided example sketch with a valid API key results in.
|
@Jason2866: I still get a 2minute responce time (as at 10Apr25): I am using "https://github.com/espressif/arduino-esp32/tree/3.2.0-RC2" as at 10Apr25. I am using an ESP32-Dev-Module. My SSID (test1) is a mobile-hotspot connected to a 4G-LTE network (O2 in the UK). -------------------------------------- Simple Output ---------------------------------------
--------------------------------------- Verbose Output ---------------------------------------
|
Related area
Significantly reduce delay
Hardware specification
All ESP32 boards
Is your feature request related to a problem?
In cases where Server sends no Content-Length header, the above
getString()
function gets "_size=-1
", and will wait as long as 2 minutes before returning.Describe the solution you'd like
Further to: #2667
re. https://github.com/espressif/arduino-esp32/blob/master/libraries/HTTPClient/src/HTTPClient.h
and https://github.com/espressif/arduino-esp32/blob/master/libraries/HTTPClient/src/HTTPClient.cpp
In cases where Server sends no Content-Length header, the above
getString()
function gets "_size=-1
", and will wait as long as 2 minutes before returning.eg. URL=http://api.openweathermap.org/data/2.5/weather?lon=-1.264&lat=52.371&units=metric&lang=en&appid=???
(The
http.setConnectTimeout(3000)
andhttp.setTimeout(3000)
commands do not change this.)A fix for this is to set a limit on the minimum data size you need (ie. the maximum to receive) as follow:
Modify "HTTPClient.h" to say:
String getString(size_t size=0);
Modify / add 1 line to "HTTPClient.cpp" to:
This allows existing "
String s=http.getString()
" commands to still work fine.But will also allow the new "
String s=http.getString(500)
" command which for the above URL example returns the data I need and reduces the wait time to under 1 second.Although this modification is not as universal as implementing a selectable-timeout on this function, it is far simpler.
I can write a PR for this if someone is able to consider approving/commiting it?
Describe alternatives you've considered
No response
Additional context
No response
I have checked existing list of Feature requests and the Contribution Guide
The text was updated successfully, but these errors were encountered: