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.

Home Page:https://docs.webp.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

bhzhu203 opened this issue · comments

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
2. want to download the original imgs (we choose this)

commented

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.

commented

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

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

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.

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