Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Reintroduce LaxRedirectStrategy in HttpClient 5.4 for Enhanced Redirect Handling #565

Merged
merged 1 commit into from
Aug 3, 2024

Conversation

otavioprado
Copy link

This commit adds a new implementation of the LaxRedirectStrategy, bringing back functionality similar to that found in HttpClient 4.x. The LaxRedirectStrategy automatically redirects all HEAD, GET, POST, and DELETE requests, relaxing the restrictions imposed by the HTTP specification on automatic redirection of POST methods.

Key Features:

  • Supported Methods: Redirects HEAD, GET, POST, and DELETE methods.
  • Location Resolution: Automatically resolves relative redirect URIs against the request URI.
  • Compatibility: Ensures compatibility with existing 4.x applications by providing a familiar API and redirect behavior.
  • Normalization: Normalizes and converts the host part of the redirect URI to lowercase, maintaining consistent behavior.

Benefits:

  • Simplifies migration from HttpClient 4.x to 5.x by providing a drop-in replacement for LaxRedirectStrategy.
  • Supports applications that rely on flexible redirect behavior for non-idempotent HTTP methods.

Usage:

CloseableHttpClient httpClient = HttpClients.custom()
    .setRedirectStrategy(LaxRedirectStrategy.INSTANCE)
    .build();

I have reopened this pull request based on the feedback provided by @ok2c. Below are the changes made to address the comments:

Changed Target Branch:

  • The target branch has been changed from the stable branch to the master (5.4) branch, as new features should not be added to stable branches.

Updated since Tag:

  • The since tag has been updated to 5.4 to reflect the correct version for this feature.

Adjusted Test Method Visibility:

  • Test methods now have package visibility to maintain consistency with existing test cases.
    Thank you for the feedback, and please let me know if there are any further changes required!

@otavioprado otavioprado changed the title added LaxRedirectStrategy from 4.x feat: Reintroduce LaxRedirectStrategy in HttpClient 5.4 for Enhanced Redirect Handling Aug 3, 2024
@ok2c ok2c merged commit df5ab53 into apache:master Aug 3, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants