webp-sh / webp_server_go

Go version of WebP Server. A tool that will serve your JPG/PNG/BMP/SVGs as WebP/AVIF format with compression, on-the-fly.
https://docs.webp.sh
GNU General Public License v3.0
1.83k stars 175 forks source link

Can not respon URL + "?response-content-type=application/octet-stream" correctly #230

Closed bhzhu203 closed 1 year ago

bhzhu203 commented 1 year ago

When using URL + "?response-content-type=application/octet-stream" to let imgs download directly (making header content-type: application/octet-stream ) ,not showing the imgs.

2 situations:

1.want to download the webp imgs

  1. want to download the original imgs (we choose this)
BennyThink commented 1 year ago

Your client application can always choose how to deal with the response.

Forcing the client(i.e. browser) to download image is not our purpose, our purpose is to converting the images on the fly.

BennyThink commented 1 year ago

My suggestion regarding this is you can add a middleware to proxy the request and set content-type as application/bin or whatever.

bhzhu203 commented 1 year ago

But alibaba cloud webp cdn can respon URL + "?response-content-type=application/octet-stream" correctly. I think that is a standar http server could be implemented . @BennyThink

n0vad3v commented 1 year ago

If you want to download the original image, a simple way is to use cURL to make requests, example as below:

curl -I localhost:3333/DSC06079.jpg
HTTP/1.1 200 OK
Server: Webp Server Go
Date: Sun, 25 Jun 2023 13:52:13 GMT
Content-Type: image/jpeg
Content-Length: 11171772
X-Compression-Rate: 1.00
Accept-Ranges: bytes
Last-Modified: Sun, 05 Mar 2023 03:27:23 GMT

Note WebP Server is serving image/jpeg (original format)

I don't think any kind of "standar http server" should support adding GET params like ?response-content-type=application/octet-stream to change the response header by visit, if "alibaba cloud webp cdn", then that's only their own implementation.

bhzhu203 commented 1 year ago

If you want to download the original image, a simple way is to use cURL to make requests, example as below:

curl -I localhost:3333/DSC06079.jpg
HTTP/1.1 200 OK
Server: Webp Server Go
Date: Sun, 25 Jun 2023 13:52:13 GMT
Content-Type: image/jpeg
Content-Length: 11171772
X-Compression-Rate: 1.00
Accept-Ranges: bytes
Last-Modified: Sun, 05 Mar 2023 03:27:23 GMT

Note WebP Server is serving image/jpeg (original format)

I don't think any kind of "standar http server" should support adding GET params like ?response-content-type=application/octet-stream to change the response header by visit, if "alibaba cloud webp cdn", then that's only their own implementation.

indeed , I have tested the nginx , nginx has no this implementation , that is the implementation of alibaba cloud OSS