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

Request.SetBody() allows overwriting with an empty body #19754

Merged
merged 3 commits into from
Jan 6, 2023

Conversation

chlowell
Copy link
Member

@chlowell chlowell commented Jan 5, 2023

Today, sending a Request without its body (Key Vault clients do this) requires copying it and/or modifying the underlying http.Request because Request.SetBody() won't overwrite a non-empty body with an empty one. This is apparently an oversight--SetBody will overwrite a non-empty body or set an empty body, but it won't do both at once.

Copy link
Member

@jhendrixMSFT jhendrixMSFT left a comment

Choose a reason for hiding this comment

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

Just needs a doc comment.

Copy link
Member

@jhendrixMSFT jhendrixMSFT left a comment

Choose a reason for hiding this comment

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

I'll leave it to you if you want to remove the Content-Type header.

@chlowell chlowell merged commit 6a1b839 into Azure:main Jan 6, 2023
@chlowell chlowell deleted the setbody branch January 6, 2023 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants