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

Implement SendFormUrlEncoded method for application/x-www-form-urlencoded form data #27

Merged

Conversation

dionrhys
Copy link
Member

In #9, the SendForm extension method was changed from sending a application/x-www-form-urlencoded request to sending one as multipart/form-data instead. This is a breaking change in some cases if sending to an endpoint that doesn't expect form data to come in with multipart/form-data encoding (OIDC access token requests for example, see opserver/Opserver#426).

This PR re-adds the old behaviour as a new extension method so consuming libraries don't need to add it back themselves.

I expect application/x-www-form-urlencoded is the more common media type that consumers will want (when size limitations or file uploads aren't a concern), but I didn't want to revert SendForm back to its original behaviour to avoid breaking dependent projects again.

I could also obsolete SendForm and provide SendMultipartForm / SendFormUrlEncoded but I don't think it's important enough to inconvenience consumers with changing their code (and getting build errors using TreatWarningsAsErrors).

@NickCraver
Copy link
Collaborator

Looking good - we should add a test to ensure the form type on both (testing is in a pretty good state for adding here), happy to help tonight if not obvious!

Copy link
Member Author

@dionrhys dionrhys left a comment

Choose a reason for hiding this comment

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

Added tests!

tests/StackExchange.Utils.Tests/HttpTests.cs Show resolved Hide resolved
@NickCraver NickCraver merged commit 2cf9dd1 into StackExchange:main Aug 29, 2023
3 checks passed
@dionrhys dionrhys deleted the dion/add-sendformurlencoded-extension branch August 30, 2023 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants