@@ -193,12 +193,7 @@ public async Task ForwardAuthorizationToExternalHost_Controls_Cross_Origin_Auth(
193193 using var externalServer = WireMockServer . Start ( ) ;
194194 externalServer
195195 . Given ( Request . Create ( ) . WithPath ( "/echo-request" ) )
196- . RespondWith ( Response . Create ( ) . WithCallback ( request => {
197- var headers = request . Headers ?
198- . ToDictionary ( x => x . Key , x => string . Join ( ", " , x . Value ) )
199- ?? new Dictionary < string , string > ( ) ;
200- return WireMockTestServer . CreateJson ( new { Method = request . Method , Headers = headers , Body = request . Body ?? "" } ) ;
201- } ) ) ;
196+ . RespondWith ( Response . Create ( ) . WithCallback ( WireMockTestServer . EchoRequest ) ) ;
202197
203198 // Main server redirects to the external server
204199 var redirectPath = $ "/redirect-external-{ allowExternal } ";
@@ -256,38 +251,27 @@ public async Task ForwardCookies_False_Should_Not_Send_Cookies_On_Redirect() {
256251
257252 // ─── ForwardBody ────────────────────────────────────────────────────
258253
259- [ Fact ]
260- public async Task ForwardBody_False_Should_Drop_Body_Even_When_Verb_Preserved ( ) {
254+ [ Theory ]
255+ [ InlineData ( false ) ]
256+ [ InlineData ( true ) ]
257+ public async Task ForwardBody_Controls_Body_Forwarding_When_Verb_Preserved ( bool forwardBody ) {
261258 using var client = CreateClient ( o =>
262- o . RedirectOptions = new RedirectOptions { ForwardBody = false }
259+ o . RedirectOptions = new RedirectOptions { ForwardBody = forwardBody }
263260 ) ;
264261
265262 var request = new RestRequest ( "/redirect-with-status?status=307" , Method . Post ) ;
266- request . AddJsonBody ( new { data = "should-be-dropped " } ) ;
263+ request . AddJsonBody ( new { data = "test-body " } ) ;
267264
268265 var response = await client . ExecuteAsync ( request ) ;
269266
270267 response . StatusCode . Should ( ) . Be ( HttpStatusCode . OK ) ;
271268 var doc = JsonDocument . Parse ( response . Content ! ) ;
272269 doc . RootElement . GetProperty ( "Method" ) . GetString ( ) . Should ( ) . Be ( "POST" ) ;
273- doc . RootElement . GetProperty ( "Body" ) . GetString ( ) . Should ( ) . BeEmpty ( ) ;
274- }
275270
276- [ Fact ]
277- public async Task ForwardBody_True_Should_Forward_Body_When_Verb_Preserved ( ) {
278- using var client = CreateClient ( o =>
279- o . RedirectOptions = new RedirectOptions { ForwardBody = true }
280- ) ;
281-
282- var request = new RestRequest ( "/redirect-with-status?status=307" , Method . Post ) ;
283- request . AddJsonBody ( new { data = "keep-me" } ) ;
284-
285- var response = await client . ExecuteAsync ( request ) ;
286-
287- response . StatusCode . Should ( ) . Be ( HttpStatusCode . OK ) ;
288- var doc = JsonDocument . Parse ( response . Content ! ) ;
289- doc . RootElement . GetProperty ( "Method" ) . GetString ( ) . Should ( ) . Be ( "POST" ) ;
290- doc . RootElement . GetProperty ( "Body" ) . GetString ( ) . Should ( ) . Contain ( "keep-me" ) ;
271+ if ( forwardBody )
272+ doc . RootElement . GetProperty ( "Body" ) . GetString ( ) . Should ( ) . Contain ( "test-body" ) ;
273+ else
274+ doc . RootElement . GetProperty ( "Body" ) . GetString ( ) . Should ( ) . BeEmpty ( ) ;
291275 }
292276
293277 // ─── ForwardQuery ───────────────────────────────────────────────────
0 commit comments