mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
chore: remove unnecessary code (#2754)
This commit is contained in:
parent
69d355eb4b
commit
21c49009c0
@ -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))
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user