-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Honor timeout in HTTPClient #6056
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
Conversation
I don't see where the write timeout is going to be different between the versions. The online |
It's not that tricky. Timeout is implemented by
Check the example, and this more readable subcommit. edit: This was tested with the (now-)fixed example and a web server using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Only minor niggle is that Stream::readBytes can return 0 for either timeout or connection loss. The handling in these cases looks good, and I suppose a dropped connection would qualify as a timeout (since you'll never get any more data). :)
if (!bytesRead) | ||
{ | ||
DEBUG_HTTPCLIENT("[HTTP-Client][writeToStreamDataBlock] input stream timeout\n"); | ||
free(buff); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using above:
std::unique_ptr<uint8_t[]> buff(new uint8_t[buff_size]);
above instead of the malloc, and removing the three free(buff) calls
fix #6033
(bug is reproduced and fixed)