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

fix: use reader over readcloser, regen cookie-jar #11482

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

powersj
Copy link
Contributor

@powersj powersj commented Jul 8, 2022

fix: use reader over readcloser, regen cookie-jar

Similar to #11083, some HTTP servers seem to quietly requires the
content-length header in messages sent. Use of Go's ReadCloser does not
allow for the content-length to be sent. As this is for a simple login
the body length will be very small and the more efficient processing of
a closer is not required in this use case.

Moves the creation of the cookie jar as well. On a re-auth, the cookie
was included in the request. Not only does this not make sense it can
cause issues on some APIs where this was not expected. Given the
original request does not contain this it seems safe to remake the
cookie jar, emptying it, for each auth request.

This also adds the ability to see the response body in the event of an
error to gain a bit more details.

fixes: #11478

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Jul 8, 2022
@powersj powersj marked this pull request as draft July 8, 2022 14:52
Similar to influxdata#11083, some HTTP servers seem to quietly requires the
content-length header in messages sent. Use of Go's ReadCloser does not
allow for the content-length to be sent. As this is for a simple login
the body length will be very small and the more efficient processing of
a closer is not required in this use case.

Moves the creation of the cookie jar as well. On a re-auth, the cookie
was included in the request. Not only does this not make sense it can
cause issues on some APIs where this was not expected. Given the
original request does not contain this it seems safe to remake the
cookie jar, emptying it, for each auth request.

This also adds the ability to see the response body in the event of an
error to gain a bit more details.

fixes: influxdata#11478
@powersj powersj changed the title fix: get cookie response body on error fix: use reader over readcloser, regen cookie-jar Jul 15, 2022
@powersj powersj marked this pull request as ready for review July 15, 2022 13:16
@powersj powersj added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Jul 15, 2022
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks @powersj!

@powersj powersj merged commit b507636 into influxdata:master Jul 18, 2022
@powersj powersj deleted the fix/11478 branch July 18, 2022 19:05
MyaLongmire pushed a commit that referenced this pull request Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP plugin code 400 on connection to Citrix ADC
2 participants