-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Introduce overloaded MockPart
constructor that accepts the Content-Type
#31757
Introduce overloaded MockPart
constructor that accepts the Content-Type
#31757
Conversation
@HyeongMokJeong Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@HyeongMokJeong Thank you for signing the Contributor License Agreement! |
MockPart
constructor that accepts the Content-Type
Hi @HyeongMokJeong, Congratulations on submitting your first PR for the Spring Framework! 👍 Out of curiosity, why do you think the content type warrants a dedicated constructor for Have you considered setting the content type after instantiating the MockPart mockPart = new MockPart("myPart", """
{"foo": "bar"}
""".getBytes());
mockPart.getHeaders().setContentType(MediaType.APPLICATION_JSON); |
Hi @sbrannen Thank you for revising the title and providing feedback. I may not have advanced skills, but I think it would be convenient if Like this
|
After taking a closer look at The rationale is that So first-class support for the content type is the only attribute missing in terms of symmetry. As an alternative, we could consider introducing a In light of that, let's keep the API minimal and go with your original proposal in this PR. |
This PR introduces a constructor to MockPart, enabling the configuration of Content-Type.
When testing controllers that expect a specific format, such as JSON, as @RequestPart, this resolves the issue of encountering a 415 status code problem.