From 70fb7e7b703467cd7fcb6e877023ddaa687c9dba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Wed, 13 Mar 2024 23:38:55 +0300 Subject: [PATCH 1/2] remove br encoding --- proxy.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/proxy.go b/proxy.go index e3e84bd0..5a9109c3 100644 --- a/proxy.go +++ b/proxy.go @@ -35,6 +35,7 @@ import ( "github.com/projectdiscovery/tinydns" errorutil "github.com/projectdiscovery/utils/errors" readerUtil "github.com/projectdiscovery/utils/reader" + sliceutil "github.com/projectdiscovery/utils/slice" stringsutil "github.com/projectdiscovery/utils/strings" "golang.org/x/net/proxy" ) @@ -239,10 +240,20 @@ func (p *Proxy) ModifyRequest(req *http.Request) error { if len(p.options.RequestMatchReplaceDSL) != 0 { _ = p.MatchReplaceRequest(req) } + p.removeBrEncoding(req) _ = p.logger.LogRequest(req, userData) return nil } +func (*Proxy) removeBrEncoding(req *http.Request) { + encodings := strings.Split(req.Header.Get("Accept-Encoding"), ",") + for i, encoding := range encodings { + encodings[i] = strings.TrimSpace(encoding) + } + encodings = sliceutil.PruneEqual(encodings, "br") + req.Header.Set("Accept-Encoding", strings.Join(encodings, ", ")) +} + // ModifyResponse func (p *Proxy) ModifyResponse(resp *http.Response) error { ctx := martian.NewContext(resp.Request) From 1ba6d04679248d17bcf4c268ba44a7942b5222c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Wed, 13 Mar 2024 23:45:35 +0300 Subject: [PATCH 2/2] minor --- proxy.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/proxy.go b/proxy.go index 5a9109c3..78b5bd88 100644 --- a/proxy.go +++ b/proxy.go @@ -246,12 +246,10 @@ func (p *Proxy) ModifyRequest(req *http.Request) error { } func (*Proxy) removeBrEncoding(req *http.Request) { - encodings := strings.Split(req.Header.Get("Accept-Encoding"), ",") - for i, encoding := range encodings { - encodings[i] = strings.TrimSpace(encoding) - } + encodings := strings.Split(strings.ReplaceAll(req.Header.Get("Accept-Encoding"), " ", ""), ",") encodings = sliceutil.PruneEqual(encodings, "br") req.Header.Set("Accept-Encoding", strings.Join(encodings, ", ")) + } // ModifyResponse