Skip to content

HTTPClient getString halts if getSize is equal -1 #2667

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
alexodus opened this issue Apr 13, 2019 · 9 comments
Closed

HTTPClient getString halts if getSize is equal -1 #2667

alexodus opened this issue Apr 13, 2019 · 9 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@alexodus
Copy link

the condition inside getString

if(_size) {

when _size==-1, is incorrect

@Jeroen88
Copy link
Contributor

If no Content-Length header is sent, _size seems to be -1 indeed. But more changes are needed than just checking for _size == -1.

@me-no-dev
Copy link
Member

@alexodus very short report mate... what happens, when it happens, why it happens, where it happens (line number or something). Give some info here :P

@alexodus
Copy link
Author

alexodus commented Apr 14, 2019

@me-no-dev I'm sorry for the short report! :P
When I call getString in a successfull request to Google IoT Core http bridge, the wemos lolin32 with Arduino ESP32 1.0.1 hangs / halts without reset itself.

This is my code that hangs:

 if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
              String payload = https.getString(); // <- halt
              Serial.println(payload);
          } 

I have to check the size of response:

 if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
            if  (https.getSize()>0) {        
              String payload = https.getString();
              Serial.println(payload);
            }
          } 

In my opinion it's a bad behaviour to permit the halt with _size==-1

@me-no-dev
Copy link
Member

seems like a viable fix :) how about you PR this line?

@me-no-dev
Copy link
Member

1.0.2 will come out (today?) so you might want to hurry :D

@alexodus
Copy link
Author

seems like a viable fix :) how about you PR this line?

no, it's no a fix, it's a simple control in my code

@alexodus
Copy link
Author

1.0.2 will come out (today?) so you might want to hurry :D

I've another issue, much more important, about HTTPClient in arduino esp32 version 1.0.2 rc2 (in 1.0.1 is ok). I hope to submit it today! :P

@stale
Copy link

stale bot commented Aug 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

3 participants