Samsung is using Akamai Image Manager to serve these files.
If I pass an Accept
header of image/jpeg,image/gif
it returns an image/jpeg
, as expected.
wget --header="Accept: image/jpeg,image/gif" http://image-us.samsung.com/SamsungUS/home/samsung-logo-191-1.jpg
--2020-11-13 11:43:58-- http://image-us.samsung.com/SamsungUS/home/samsung-logo-191-1.jpg
Resolving image-us.samsung.com (image-us.samsung.com)... 23.217.144.69
Connecting to image-us.samsung.com (image-us.samsung.com)|23.217.144.69|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 83094 (81K) [image/jpeg]
Saving to: ‘samsung-logo-191-1.jpg.6’
Discourse, tries to fetch the image by calling FileHelper.download
, which calls FinalDestination.get
, which ultimately requests the file with a UserAgent
of:
Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36
So, if we request the same image with the same Accept
header as above, but adding in that user agent, we get:
wget --header="Accept: image/jpeg,image/gif" --header="User-Agent: Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" http://image-us.samsung.com/SamsungUS/home/samsung-logo-191-1.jpg
--2020-11-13 11:52:50-- http://image-us.samsung.com/SamsungUS/home/samsung-logo-191-1.jpg
Resolving image-us.samsung.com (image-us.samsung.com)... 23.217.144.69
Connecting to image-us.samsung.com (image-us.samsung.com)|23.217.144.69|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 45540 (44K) [image/webp]
Saving to: ‘samsung-logo-191-1.jpg.10’
And it’s returned a image/webp
. It appears as though they’re ignoring the Accept
header, and using their own logic to determine the best file type based on the user agent.
Apple hasn’t supported webp historically, so let’s try that:
wget --header="Accept: image/jpeg,image/gif" --header="User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15" http://image-us.samsung.com/SamsungUS/home/samsung-logo-191-1.jpg
--2020-11-13 12:27:02-- http://image-us.samsung.com/SamsungUS/home/samsung-logo-191-1.jpg
Resolving image-us.samsung.com (image-us.samsung.com)... 23.217.144.69
Connecting to image-us.samsung.com (image-us.samsung.com)|23.217.144.69|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 83094 (81K) [image/jpeg]
Saving to: ‘samsung-logo-191-1.jpg.16’
Success!
I think you can make a pretty strong argument that the webserver should always respect the Accept
header and not try to outsmart it. On the other hand, someone could argue that if you present a specific user agent string, you should be prepared to act like that user agent (although user agent spoofing isn’t uncommon and has a variety of uses).
As it happens, Apple has added webp support to iOS14 (released recently) and MacOS Big Sur (released yesterday), so we probably should support that (by adding it as a default allowed extension) and by configuring ImageMagick to support it (which will introduce a dependency on libwebp or similar) so we can optimize and resize, etc.