Fix support for following redirects added by previous merge #4385
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ee88c42 added support for following redirects (#4240)
However I couldn't make it work because of 2 issues in HTTPClient.cpp:
in the newly added setURL() we do "_canReuse = true" which means we preserve the client but kill the connection. The latter invalidates some of the memory which means that later _client.available() or similar blow up completely
getString() doesn't deal with when _size == -1 which can be a valid state (see existing comment re "Server not sending Content-Length header"). I've changed that condition to how it was in one of the previous versions and removed the optimisation around reserving memory upfront, as this seems to be done later on just fine..
It's my first time I contribute to this project so please bear with me if I got things wrong 👍
Dan