fix(test): use DefaultTransport.RoundTrip and preserve query string in rewriteHostTransport
Address Copilot review feedback: - Switch from http.DefaultClient.Do to http.DefaultTransport.RoundTrip to avoid unexpected redirect handling in test helper - Preserve req.URL.RawQuery when rewriting URLs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
310c644e09
commit
45f21bca10
1 changed files with 4 additions and 1 deletions
|
|
@ -883,12 +883,15 @@ func TestExaSearchProvider_MaxResultsCapping(t *testing.T) {
|
|||
func rewriteHostTransport(target string) http.RoundTripper {
|
||||
return roundTripFunc(func(req *http.Request) (*http.Response, error) {
|
||||
newURL := target + req.URL.Path
|
||||
if req.URL.RawQuery != "" {
|
||||
newURL += "?" + req.URL.RawQuery
|
||||
}
|
||||
newReq, err := http.NewRequestWithContext(req.Context(), req.Method, newURL, req.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newReq.Header = req.Header
|
||||
return http.DefaultClient.Do(newReq)
|
||||
return http.DefaultTransport.RoundTrip(newReq)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue