File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
src/main/java/com/twilio/http Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 1212import org .apache .hc .client5 .http .classic .methods .HttpUriRequestBase ;
1313import org .apache .hc .client5 .http .config .RequestConfig ;
1414import org .apache .hc .client5 .http .impl .DefaultRedirectStrategy ;
15+ import org .apache .hc .core5 .http .protocol .HttpContext ;
1516import org .apache .hc .client5 .http .protocol .RedirectStrategy ;
1617import org .apache .hc .core5 .http .ContentType ;
18+ import org .apache .hc .core5 .http .HttpRequest ;
19+ import org .apache .hc .core5 .http .HttpResponse ;
20+ import org .apache .hc .core5 .http .ProtocolException ;
1721import org .apache .hc .core5 .http .io .SocketConfig ;
1822import org .apache .hc .core5 .util .Timeout ;
1923
@@ -57,10 +61,21 @@ public abstract class HttpClient {
5761 public static final int RETRIES = 3 ;
5862 public static final long DELAY_MILLIS = 100L ;
5963
64+ /**
65+ * Custom redirect strategy that disables automatic redirects.
66+ */
67+ private static class TwilioRedirectStrategy extends DefaultRedirectStrategy {
68+ @ Override
69+ public boolean isRedirected (HttpRequest request , HttpResponse response , HttpContext context ) throws ProtocolException {
70+ // Disable all automatic redirects
71+ return false ;
72+ }
73+ }
74+
6075 // Default redirect strategy to not auto-redirect for any methods (empty string array).
6176 @ Getter
6277 @ Setter
63- private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy ();
78+ private RedirectStrategy redirectStrategy = new TwilioRedirectStrategy ();
6479
6580 @ Getter
6681 private Response lastResponse ;
You can’t perform that action at this time.
0 commit comments