feat: Add support for optional follow_redirects #526
Open
srlynch1 wants to merge 3 commits intohashicorp:mainfrom
Open
feat: Add support for optional follow_redirects #526srlynch1 wants to merge 3 commits intohashicorp:mainfrom
srlynch1 wants to merge 3 commits intohashicorp:mainfrom
Conversation
- Added a new optional attribute `follow_redirects` to control HTTP redirect behavior. - Updated the `Read` method to handle the no-follow behavior when `follow_redirects` is set to false. - Introduced a new test `TestDataSource_FollowRedirects` to verify the functionality of the redirect handling.
heldersepu
approved these changes
May 31, 2025
heldersepu
left a comment
There was a problem hiding this comment.
for what is worth this change looks good ...
it enhances the provider without disrupting default behavior
heldersepu
reviewed
May 31, 2025
| Config: fmt.Sprintf(` | ||
| data "http" "http_test" { | ||
| url = %q | ||
| follow_redirects = false |
There was a problem hiding this comment.
IF you want to go the extra mile add a test with follow_redirects = true
rainkwan
reviewed
Jun 30, 2025
| }, | ||
|
|
||
| "follow_redirects": schema.BoolAttribute{ | ||
| Description: "If false, do not follow HTTP redirects. Defaults to true.", |
Contributor
There was a problem hiding this comment.
Suggested change
| Description: "If false, do not follow HTTP redirects. Defaults to true.", | |
| Description: "If `false`, does not follow HTTP redirects. Defaults to `true`.", |
rainkwan
reviewed
Jun 30, 2025
| - `ca_cert_pem` (String) Certificate Authority (CA) in [PEM (RFC 1421)](https://datatracker.ietf.org/doc/html/rfc1421) format. | ||
| - `client_cert_pem` (String) Client certificate in [PEM (RFC 1421)](https://datatracker.ietf.org/doc/html/rfc1421) format. | ||
| - `client_key_pem` (String) Client key in [PEM (RFC 1421)](https://datatracker.ietf.org/doc/html/rfc1421) format. | ||
| - `follow_redirects` (Boolean) If false, do not follow HTTP redirects. Defaults to true. |
Contributor
There was a problem hiding this comment.
Suggested change
| - `follow_redirects` (Boolean) If false, do not follow HTTP redirects. Defaults to true. | |
| - `follow_redirects` (Boolean) If `false`, does not follow HTTP redirects. Defaults to `true`. |
Contributor
|
Hi @srlynch1, thank you for your contribution! 😄 This looks pretty reasonable, I just wanted to ask if you could create a changelog entry for this as an enhancement. |
Author
|
this is a CI problem it should be automated use AI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This feature implements an optional attribute follow_redirects, the default behaviour today is to directly follow the Location header.
Some APIs expect data is read from the Location header, rather than directly followed. A common example of this is Red Hat OpenShift oauth authentication flow.
This feature allows for an optional attribute follow_redirects = false, in this scenario the Location header redirect will not be followed and returned headers will be available in the the headers map.
If optional follow_redirects is either true or not supplied the behaviour is as it is today.