Change check for /events EP from using HEAD to timed GET #2
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.
ESPHome no longer implements the HEAD HTTP method and will respond
with "HTTP/1.1 405 Method Not Allowed". This doesn't help us check if
the /events endpoint exists.
Even though the /events endpoint will stream indefinitely, if we
impose a max-time (-m) in curl, curl will end the connection and return
the initial HTTP GET's status code (hopefully 200).
We could make this max-time some fraction of a second, like 10 to 100ms,
but I would worry about sleepy devices that are on very weak wifi
connections. This 2 second timeout is a one time thing, so let's not
over optimize.
We change the powershell version to use curl for this check, since the
Invoke-WebRequest method's TimeoutSec parameter only governs the time
to get the first response from the server, so it runs forever.
To implement the same curl logic seems to require many more complicated
powershell lines, so lets just fall back to the same curl test that we
do in bash. This is arguably more maintainable.
Fixes #1