chore: remove unnecessary code (#2754)

This commit is contained in:
chen quan 2023-01-05 22:12:07 +08:00 committed by GitHub
parent 69d355eb4b
commit 21c49009c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -7,7 +7,6 @@ import (
"fmt"
"io"
"net/http"
"net/http/httptrace"
nurl "net/url"
"strings"
@ -176,11 +175,6 @@ func request(r *http.Request, cli client) (*http.Response, error) {
respHandlers[i] = h
}
clientTrace := httptrace.ContextClientTrace(ctx)
if clientTrace != nil {
ctx = httptrace.WithClientTrace(ctx, clientTrace)
}
r = r.WithContext(ctx)
propagator.Inject(ctx, propagation.HeaderCarrier(r.Header))

View File

@ -5,6 +5,7 @@ import (
"net/http"
"net/http/httptest"
"net/http/httptrace"
"strings"
"testing"
"github.com/stretchr/testify/assert"
@ -205,12 +206,14 @@ func TestDo_WithClientHttpTrace(t *testing.T) {
svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}))
defer svr.Close()
enter := false
_, err := Do(httptrace.WithClientTrace(context.Background(),
&httptrace.ClientTrace{
DNSStart: func(info httptrace.DNSStartInfo) {
assert.Equal(t, "localhost", info.Host)
GetConn: func(hostPort string) {
assert.Equal(t, "127.0.0.1", strings.Split(hostPort, ":")[0])
enter = true
},
}), http.MethodGet, svr.URL, nil)
assert.Nil(t, err)
assert.True(t, enter)
}