Skip to content

Commit 3f34abe

Browse files
committed
test cleanup
1 parent 8c64a38 commit 3f34abe

File tree

2 files changed

+142
-169
lines changed

2 files changed

+142
-169
lines changed

main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func main() {
7676
slog.Info("imgproxy is ready")
7777

7878
proxy := httputil.NewSingleHostReverseProxy(target)
79+
7980
proxy.ModifyResponse = func(resp *http.Response) error {
8081
if resp.StatusCode == http.StatusOK {
8182
// Read the entire response body into a buffer
@@ -93,9 +94,15 @@ func main() {
9394
// Replace the response body with our buffered copy
9495
resp.Body = io.NopCloser(respReader)
9596

97+
// Use RawPath if available (preserves URL encoding), otherwise use Path
98+
originalPath := resp.Request.URL.Path
99+
if resp.Request.URL.RawPath != "" {
100+
originalPath = resp.Request.URL.RawPath
101+
}
102+
96103
// Upload the complete file to S3 in a goroutine
97104
go func() {
98-
if err := uploadToS3(context.Background(), uploader, cfg, s3Reader, resp.Request.URL.Path); err != nil {
105+
if err := uploadToS3(context.Background(), uploader, cfg, s3Reader, originalPath); err != nil {
99106
slog.Error("S3 upload failed", "error", err)
100107
}
101108
}()

0 commit comments

Comments
 (0)