Skip to content

Conversation

srlynch1
Copy link

@srlynch1 srlynch1 commented Apr 27, 2025

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.

srlynch1 and others added 2 commits April 23, 2025 18:16
- 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.
@srlynch1 srlynch1 requested a review from a team as a code owner April 27, 2025 23:18
@github-actions github-actions bot added size/M and removed size/S labels Apr 28, 2025
@srlynch1 srlynch1 mentioned this pull request May 12, 2025
1 task
Copy link

@heldersepu heldersepu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for what is worth this change looks good ...
it enhances the provider without disrupting default behavior

Config: fmt.Sprintf(`
data "http" "http_test" {
url = %q
follow_redirects = false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IF you want to go the extra mile add a test with follow_redirects = true

@rainkwan rainkwan mentioned this pull request Jun 18, 2025
1 task
},

"follow_redirects": schema.BoolAttribute{
Description: "If false, do not follow HTTP redirects. Defaults to true.",
Copy link
Contributor

@rainkwan rainkwan Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Description: "If false, do not follow HTTP redirects. Defaults to true.",
Description: "If `false`, does not follow HTTP redirects. Defaults to `true`.",

- `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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`.

@rainkwan
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants