Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions common/httpx/httpx.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,7 @@ func (h *HTTPX) NewRequestWithContext(ctx context.Context, method, targetURL str
}
// Skip if unsafe is used
if !h.Options.Unsafe {
// set default user agent
req.Header.Set("User-Agent", h.Options.DefaultUserAgent)
// set default encoding to accept utf8
req.Header.Add("Accept-Charset", "utf-8")
}
return
}
Expand Down
9 changes: 9 additions & 0 deletions common/httpx/httpx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,3 +539,12 @@ func TestDoExtractCSP(t *testing.T) {
require.Nil(t, resp.BodyDomains)
})
}

// Browsers no longer send Accept-Charset and some WAFs block it (discussion #2242).
func TestNewRequestOmitsAcceptCharset(t *testing.T) {
h := &HTTPX{Options: &Options{DefaultUserAgent: "httpx"}}
req, err := h.NewRequest(http.MethodGet, "https://example.com")
require.NoError(t, err)
require.NotContains(t, req.Header, "Accept-Charset")
require.Equal(t, "httpx", req.Header.Get("User-Agent"))
}
Loading