add webp support (decode only)

if any transformation is requested, webp images will be encoded and
served as jpeg or png, defaulting to jpeg if no format is specified.

Fixes #88
This commit is contained in:
Will Norris 2017-06-01 08:10:34 -07:00
parent b9cc9df4b6
commit 328044540e
3 changed files with 14 additions and 3 deletions

View file

@ -308,7 +308,8 @@ func (t *TransformingTransport) RoundTrip(req *http.Request) (*http.Response, er
fmt.Fprintf(buf, "%s %s\n", resp.Proto, resp.Status)
resp.Header.WriteSubset(buf, map[string]bool{
"Content-Length": true,
"Content-Type": opt.Format != "",
// exclude Content-Type header if the format may have changed during transformation
"Content-Type": opt.Format != "" || resp.Header.Get("Content-Type") == "image/webp",
})
fmt.Fprintf(buf, "Content-Length: %d\n\n", len(img))
buf.Write(img)