From 2af81695bdc64e76d66206c217bb3ed2cba5ade4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20K=C3=B6hlbrugge?= Date: Fri, 19 Mar 2021 12:23:39 +0000 Subject: [PATCH 1/4] Fix typo ('sorce' to 'source') (#587) --- docs/getting_the_image_info.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_the_image_info.md b/docs/getting_the_image_info.md index efc44c99..de38fe8d 100644 --- a/docs/getting_the_image_info.md +++ b/docs/getting_the_image_info.md @@ -29,7 +29,7 @@ The source URL can be provided as is, prepended by `/plain/` part: /plain/http://example.com/images/curiosity.jpg ``` -**📝Note:** If the sorce URL contains query string or `@`, you need to escape it. +**📝Note:** If the source URL contains query string or `@`, you need to escape it. #### Base64 encoded From a89803dfe56c14de2218ab9bc3173a82542ba830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20K=C3=B6hlbrugge?= Date: Fri, 19 Mar 2021 12:23:48 +0000 Subject: [PATCH 2/4] Remove double 'p' in 'Exampple' (#588) --- docs/getting_the_image_info.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_the_image_info.md b/docs/getting_the_image_info.md index de38fe8d..c1c025ea 100644 --- a/docs/getting_the_image_info.md +++ b/docs/getting_the_image_info.md @@ -67,7 +67,7 @@ imgproxy responses with JSON body and returns the following info: } ``` -#### Exampple (mp4) +#### Example (mp4) ```json { From 83c4ef1ea85fc00646479daa2ed759c217d9565a Mon Sep 17 00:00:00 2001 From: Joshua Banton Date: Mon, 22 Mar 2021 10:03:13 -0400 Subject: [PATCH 3/4] Removes checking for mdat box before meta box. (#585) --- imagemeta/heif.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/imagemeta/heif.go b/imagemeta/heif.go index dd338091..f54346e0 100644 --- a/imagemeta/heif.go +++ b/imagemeta/heif.go @@ -210,8 +210,6 @@ func heifReadBoxes(d *heifData, r io.Reader) error { if w > d.Width || h > d.Height { d.Width, d.Height = w, h } - case "mdat": - return errors.New("mdat box occurred before meta box") default: if err := heifDiscardN(r, boxDataSize); err != nil { return err From c7fcb9b94f57dee891eb63d305b2217f673c19d9 Mon Sep 17 00:00:00 2001 From: Ewan Higgs Date: Thu, 25 Mar 2021 11:43:30 +0100 Subject: [PATCH 4/4] Allow compression at the transport level. (#595) * Allow compression at the transport level. * Do not enable compression but do decompress compressed content-encodings. * Fix import in download.go to use std compress/go. * Fix issue with err shadowing. * Don't overwrite resBody on download of original image. Set content length to 0 if data was compressed. --- download.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/download.go b/download.go index 14137eb3..46df4bc1 100644 --- a/download.go +++ b/download.go @@ -1,6 +1,7 @@ package main import ( + "compress/gzip" "context" "crypto/tls" "fmt" @@ -200,7 +201,22 @@ func downloadImage(ctx context.Context) (context.Context, context.CancelFunc, er return ctx, func() {}, err } - imgdata, err := readAndCheckImage(res.Body, int(res.ContentLength)) + body := res.Body + contentLength := int(res.ContentLength) + + if res.Header.Get("Content-Encoding") == "gzip" { + gzipBody, errGzip := gzip.NewReader(res.Body) + if gzipBody != nil { + defer gzipBody.Close() + } + if errGzip != nil { + return ctx, func() {}, err + } + body = gzipBody + contentLength = 0 + } + + imgdata, err := readAndCheckImage(body, contentLength) if err != nil { return ctx, func() {}, err }