From 0270c003ff8f4e6f6ad656d63ce093fca12f37c7 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Wed, 6 Dec 2023 13:54:24 -0800 Subject: [PATCH] Refactor 4bc279bfefcf94d2049aee9801efd418a12e0314 (#22111) Make the fix in a non-breaking way. --- sdk/internal/recording/recording.go | 12 +++++++----- .../TestRecording/TestGenerateAlphaNumericID.json | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sdk/internal/recording/recording.go b/sdk/internal/recording/recording.go index df82a14b8cb5..22dc78f6a5de 100644 --- a/sdk/internal/recording/recording.go +++ b/sdk/internal/recording/recording.go @@ -537,10 +537,10 @@ func defaultOptions() *RecordingOptions { } } -func (r RecordingOptions) ReplaceAuthority(t *testing.T, rawReq *http.Request) (*http.Request, string, string) { - originalURLScheme := rawReq.URL.Scheme - originalURLHost := rawReq.URL.Host +func (r RecordingOptions) ReplaceAuthority(t *testing.T, rawReq *http.Request) *http.Request { if GetRecordMode() != LiveMode && !IsLiveOnly(t) { + originalURLHost := rawReq.URL.Host + // don't modify the original request cp := *rawReq cpURL := *cp.URL @@ -556,7 +556,7 @@ func (r RecordingOptions) ReplaceAuthority(t *testing.T, rawReq *http.Request) ( cp.Header.Set(IDHeader, GetRecordingId(t)) rawReq = &cp } - return rawReq, originalURLScheme, originalURLHost + return rawReq } func (r RecordingOptions) host() string { @@ -941,7 +941,9 @@ type RecordingHTTPClient struct { } func (c RecordingHTTPClient) Do(req *http.Request) (*http.Response, error) { - req, origScheme, origHost := c.options.ReplaceAuthority(c.t, req) + origScheme := req.URL.Scheme + origHost := req.URL.Host + req = c.options.ReplaceAuthority(c.t, req) resp, err := c.defaultClient.Do(req) if err != nil { return nil, err diff --git a/sdk/internal/recording/testdata/recordings/TestRecording/TestGenerateAlphaNumericID.json b/sdk/internal/recording/testdata/recordings/TestRecording/TestGenerateAlphaNumericID.json index f7f287bc1d2d..6c9ca58c3a2d 100644 --- a/sdk/internal/recording/testdata/recordings/TestRecording/TestGenerateAlphaNumericID.json +++ b/sdk/internal/recording/testdata/recordings/TestRecording/TestGenerateAlphaNumericID.json @@ -1,6 +1,6 @@ { "Entries": [], "Variables": { - "randSeed": "1701821574" + "randSeed": "1701896129" } }