1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-04-01 20:34:23 +02:00

Patch GCS transport

This commit is contained in:
DarthSim 2022-04-07 20:39:39 +06:00
parent b614b41723
commit 902123d95e

View File

@ -8,8 +8,9 @@ import (
"strings"
"cloud.google.com/go/storage"
"github.com/imgproxy/imgproxy/v3/config"
"google.golang.org/api/option"
"github.com/imgproxy/imgproxy/v3/config"
)
type transport struct {
@ -46,13 +47,13 @@ func (t transport) RoundTrip(req *http.Request) (*http.Response, error) {
header := make(http.Header)
if config.ETagEnabled {
attrs, err := obj.Attrs(context.Background())
attrs, err := obj.Attrs(req.Context())
if err != nil {
return nil, err
}
header.Set("ETag", attrs.Etag)
if attrs.Etag == req.Header.Get("If-None-Match") {
if etag := req.Header.Get("If-None-Match"); len(etag) > 0 && attrs.Etag == etag {
return &http.Response{
StatusCode: http.StatusNotModified,
Proto: "HTTP/1.0",
@ -67,7 +68,7 @@ func (t transport) RoundTrip(req *http.Request) (*http.Response, error) {
}
}
reader, err := obj.NewReader(context.Background())
reader, err := obj.NewReader(req.Context())
if err != nil {
return nil, err
}