File tree Expand file tree Collapse file tree 3 files changed +33
-5
lines changed
main/java/reactor/netty/http/client
test/java/reactor/netty/http/client Expand file tree Collapse file tree 3 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -741,11 +741,19 @@ protected HttpMessage outboundHttpMessage() {
741741
742742 final boolean notRedirected (HttpResponse response ) {
743743 if (isFollowRedirect () && followRedirectPredicate .test (this , this )) {
744+ try {
745+ redirecting = new RedirectClientException (response .headers (), response .status ());
746+ }
747+ catch (RuntimeException e ) {
748+ if (log .isDebugEnabled ()) {
749+ log .debug (format (channel (), "The request cannot be redirected" ), e );
750+ }
751+ return true ;
752+ }
744753 if (log .isDebugEnabled ()) {
745754 log .debug (format (channel (), "Received redirect location: {}" ),
746755 httpMessageLogFactory ().debug (HttpMessageArgProviderFactory .create (response )));
747756 }
748- redirecting = new RedirectClientException (response .headers (), response .status ());
749757 return false ;
750758 }
751759 return true ;
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2011-2022 VMware, Inc. or its affiliates, All Rights Reserved.
2+ * Copyright (c) 2011-2023 VMware, Inc. or its affiliates, All Rights Reserved.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@ final class RedirectClientException extends RuntimeException {
3131 final HttpResponseStatus status ;
3232
3333 RedirectClientException (HttpHeaders headers , HttpResponseStatus status ) {
34- location = Objects .requireNonNull (headers .get (HttpHeaderNames .LOCATION ));
35- this .status = Objects .requireNonNull (status );
34+ location = Objects .requireNonNull (headers .get (HttpHeaderNames .LOCATION ), "location" );
35+ this .status = Objects .requireNonNull (status , "status" );
3636 }
3737
3838 @ Override
Original file line number Diff line number Diff line change 11/*
2- * Copyright (c) 2017-2022 VMware, Inc. or its affiliates, All Rights Reserved.
2+ * Copyright (c) 2017-2023 VMware, Inc. or its affiliates, All Rights Reserved.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -798,4 +798,24 @@ void testHttp2Redirect() {
798798 assertThat (response .getT2 ()).isEqualTo (200 );
799799 assertThat (response .getT1 ()).isEqualTo ("OK" );
800800 }
801+
802+ @ Test
803+ void testIssue2670 () {
804+ disposableServer =
805+ createServer ()
806+ .handle ((req , res ) -> res .sendString (Mono .just ("testIssue2670" )))
807+ .bindNow ();
808+
809+ createClient (disposableServer .port ())
810+ .followRedirect ((req , res ) -> true )
811+ .get ()
812+ .uri ("/" )
813+ .responseContent ()
814+ .aggregate ()
815+ .asString ()
816+ .as (StepVerifier ::create )
817+ .expectNext ("testIssue2670" )
818+ .expectComplete ()
819+ .verify (Duration .ofSeconds (5 ));
820+ }
801821}
You can’t perform that action at this time.
0 commit comments