[online_image] Set Accept header - #8216
Conversation
The HTTP Accept request header indicates which content types, expressed as MIME types, the sender is able to understand. In requests, the server uses content negotiation to select one of the proposals. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
|
Hey there @clydebarrow, @guillempages, mind taking a look at this pull request as it has been labeled with an integration ( |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #8216 +/- ##
==========================================
+ Coverage 53.70% 53.81% +0.10%
==========================================
8000
Files 50 50
Lines 9408 9856 +448
Branches 1654 1360 -294
==========================================
+ Hits 5053 5304 +251
- Misses 4056 4230 +174
- Partials 299 322 +23 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Have you tested this with the arduino framework as well? AFAIK, the http_request implementation is very different for both esp_idf and arduino.
|
Is there a use case that you have encountered for this? If the accept is still falling back to accepting everything anyway, and the user already needs to know which format the downloaded image is in, what's the point of adding the accept header at all? In which way does this help? (Just trying to understand; not trying to reject the change) |
Servers use the accept header to respond with the correctly formatted image. For example, I'm generating webp or png based on the By having |
|
Ok, I wouldn't have expected that for the esphome devices this is actually a use case. I would have expected people to just download existing images, or have a server explicitly generating the image for ESPHome, so there would be no need for the accept headers. Nevertheless, this is an improvement so I have no objection to getting this in. |
What does this implement/fix?
The HTTP Accept request header indicates which content types, expressed as MIME types, the sender is able to understand. In requests, the server uses content negotiation to select one of the proposals.
See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
Types of changes
Related issue or feature (if applicable):
n/a
Pull request in esphome-docs with documentation (if applicable):
n/a
Test Environment
Example entry for
config.yaml:Any example would work, such as the one shown in https://esphome.io/components/online_image.html
Checklist:
tests/folder).If user exposed functionality or configuration variables are added/changed: