Skip to content

Commit

Permalink
Revert "temporarily revertback to memory buffer"
Browse files Browse the repository at this point in the history
This reverts commit e4f63ac.
  • Loading branch information
rucciva committed Sep 1, 2022
1 parent b661362 commit c30eb77
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/subtle"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/http/httputil"
Expand Down Expand Up @@ -63,7 +62,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
return
}
// defer proxyReq.Body.Close()
defer proxyReq.Body.Close()

url := url.URL{Scheme: proxyReq.URL.Scheme, Host: proxyReq.Host}
proxy := httputil.NewSingleHostReverseProxy(&url)
Expand All @@ -83,20 +82,15 @@ func (h *Handler) signWithTime(signer *v4.Signer, req *http.Request, region stri
body = fakeseeker{req.Body}

} else if !digested && req.Body != nil {
// f, err := newFilebuffer()
// if err != nil {
// return fmt.Errorf("unable to create file buffer: %w", err)
// }
// _, err = io.Copy(f, req.Body)
// if err != nil {
// return err
// }
// body = f
b, err := ioutil.ReadAll(req.Body)
f, err := newFilebuffer()
if err != nil {
return fmt.Errorf("unable to create file buffer: %w", err)
}
_, err = io.Copy(f, req.Body)
if err != nil {
return err
}
body = bytes.NewReader(b)
body = f
}

_, err := signer.Sign(req, body, "s3", region, signTime)
Expand Down

0 comments on commit c30eb77

Please sign in to comment.