Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release UseHostHeader in ReleaseRequest() #1185

Merged
merged 3 commits into from Dec 28, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions http.go
Expand Up @@ -960,6 +960,7 @@ func (req *Request) Reset() {
req.Header.Reset()
req.resetSkipHeader()
req.timeout = 0
req.UseHostHeader = false
}

func (req *Request) resetSkipHeader() {
Expand Down
14 changes: 14 additions & 0 deletions http_test.go
Expand Up @@ -757,6 +757,7 @@ func TestUseHostHeader(t *testing.T) {
}

func TestUseHostHeader2(t *testing.T) {
t.Parallel()
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Host != "SomeHost" {
http.Error(w, fmt.Sprintf("Expected Host header to be '%s', but got '%s'", "SomeHost", r.Host), http.StatusBadRequest)
Expand Down Expand Up @@ -791,6 +792,19 @@ func TestUseHostHeader2(t *testing.T) {
}
}

func TestUseHostHeaderAfterRelease(t *testing.T) {
t.Parallel()
req := AcquireRequest()
req.UseHostHeader = true
ReleaseRequest(req)

req = AcquireRequest()
defer ReleaseRequest(req)
if req.UseHostHeader {
t.Fatalf("UseHostHeader was not released in ReleaseRequest()")
}
}

func TestRequestBodyStreamMultipleBodyCalls(t *testing.T) {
t.Parallel()

Expand Down