Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
fix: run gunzip only otherwise pass through
Browse files Browse the repository at this point in the history
  • Loading branch information
eitu5ami committed Dec 11, 2023
1 parent bb44fd7 commit 7b39945
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 112 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21-alpine3.18 AS builder
FROM golang:1.21-alpine3.19 AS builder

RUN apk add --update-cache \
git \
Expand Down
43 changes: 0 additions & 43 deletions internal/middleware/gzip.go

This file was deleted.

65 changes: 0 additions & 65 deletions internal/middleware/gzip_test.go

This file was deleted.

8 changes: 5 additions & 3 deletions internal/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import (
"io"
"net/http"
"net/http/httputil"
"strings"
"time"

"github.com/0xProject/rpc-gateway/internal/middleware"
"github.com/go-http-utils/headers"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
Expand Down Expand Up @@ -113,10 +115,10 @@ func (h *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
pw := NewResponseWriter()
r.Body = io.NopCloser(bytes.NewBuffer(body.Bytes()))

if target.Config.Connection.HTTP.Compression {
middleware.Gzip(target.Proxy).ServeHTTP(pw, r)
} else {
if !target.Config.Connection.HTTP.Compression && strings.Contains(r.Header.Get(headers.ContentEncoding), "gzip") {
middleware.Gunzip(target.Proxy).ServeHTTP(pw, r)
} else {
target.Proxy.ServeHTTP(pw, r)
}

if h.HasNodeProviderFailed(pw.statusCode) {
Expand Down

0 comments on commit 7b39945

Please sign in to comment.