-
Notifications
You must be signed in to change notification settings - Fork 120
feat: Add support for optional follow_redirects #526
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
base: main
Are you sure you want to change the base?
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
}, | ||
|
||
"follow_redirects": schema.BoolAttribute{ | ||
Description: "If false, do not follow HTTP redirects. Defaults to true.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `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`. |
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. |
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.