@@ -140,7 +140,6 @@ func TestRewritePassthroughRequest(t *testing.T) {
140140 reqRemoteAddr string
141141 reqHeaders http.Header
142142 reqTLS bool
143- baseURL string
144143 provider * testutil.MockProvider
145144 expectURL string
146145 expectHeaders http.Header
@@ -149,7 +148,6 @@ func TestRewritePassthroughRequest(t *testing.T) {
149148 name : "sets_upstream_url_and_forwarded_headers_from_client_peer" ,
150149 reqPath : "http://client-host/chat?stream=true" ,
151150 reqRemoteAddr : "1.1.1.1:1111" ,
152- baseURL : "https://upstream-host/base" ,
153151 provider : & testutil.MockProvider {URL : "https://upstream-host/base" },
154152 expectURL : "https://upstream-host/base/chat?stream=true" ,
155153 expectHeaders : http.Header {
@@ -164,7 +162,6 @@ func TestRewritePassthroughRequest(t *testing.T) {
164162 reqPath : "http://client-host/chat" ,
165163 reqRemoteAddr : "1.1.1.1:1111" ,
166164 reqHeaders : http.Header {"User-Agent" : {"custom-agent/1.0" }},
167- baseURL : "https://upstream-host/base" ,
168165 provider : & testutil.MockProvider {URL : "https://upstream-host/base" },
169166 expectURL : "https://upstream-host/base/chat" ,
170167 expectHeaders : http.Header {
@@ -178,7 +175,6 @@ func TestRewritePassthroughRequest(t *testing.T) {
178175 name : "injects_auth_header" ,
179176 reqPath : "http://client-host/chat" ,
180177 reqRemoteAddr : "1.1.1.1:1111" ,
181- baseURL : "https://upstream-host/base" ,
182178 provider : & testutil.MockProvider {
183179 URL : "https://upstream-host/base" ,
184180 InjectAuthHeaderFunc : func (h * http.Header ) {
@@ -201,7 +197,6 @@ func TestRewritePassthroughRequest(t *testing.T) {
201197 reqHeaders : http.Header {
202198 "X-Forwarded-For" : {"2.2.2.2, 3.3.3.3" },
203199 },
204- baseURL : "https://upstream-host/base" ,
205200 provider : & testutil.MockProvider {URL : "https://upstream-host/base" },
206201 expectURL : "https://upstream-host/base/chat" ,
207202 expectHeaders : http.Header {
@@ -211,14 +206,27 @@ func TestRewritePassthroughRequest(t *testing.T) {
211206 "User-Agent" : {"aibridge" },
212207 },
213208 },
209+ {
210+ name : "tls_request_sets_forwarded_proto_to_https" ,
211+ reqPath : "http://client-host/chat" ,
212+ reqRemoteAddr : "1.1.1.1:1111" ,
213+ reqTLS : true ,
214+ provider : & testutil.MockProvider {URL : "https://upstream-host/base" },
215+ expectURL : "https://upstream-host/base/chat" ,
216+ expectHeaders : http.Header {
217+ "X-Forwarded-Host" : {"client-host" },
218+ "X-Forwarded-Proto" : {"https" },
219+ "X-Forwarded-For" : {"1.1.1.1" },
220+ "User-Agent" : {"aibridge" },
221+ },
222+ },
214223 {
215224 name : "omits_forwarded_for_when_remote_addr_is_not_parseable" ,
216225 reqPath : "http://client-host/chat" ,
217226 reqRemoteAddr : "not-a-socket-address" ,
218227 reqHeaders : http.Header {
219228 "X-Forwarded-For" : {"1.1.1.1" },
220229 },
221- baseURL : "https://upstream-host/base" ,
222230 provider : & testutil.MockProvider {URL : "https://upstream-host/base" },
223231 expectURL : "https://upstream-host/base/chat" ,
224232 expectHeaders : http.Header {
@@ -239,7 +247,7 @@ func TestRewritePassthroughRequest(t *testing.T) {
239247 if tc .reqTLS {
240248 r .TLS = & tls.ConnectionState {}
241249 }
242- provBaseURL , err := url .Parse (tc .baseURL )
250+ provBaseURL , err := url .Parse (tc .provider . URL )
243251 assert .NoError (t , err )
244252
245253 pr := & httputil.ProxyRequest {
0 commit comments