-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Make Content-Type optional in file upload #1385
Comments
I had a quick look and it doesn't seem to be easily possible because the underlying library used to write the body (Apache HttpClient) always sets the inner Content-Type. I tried replacing it with OkHttp but that always included a Maybe the best way would be to just write it ourselves instead of using a library? Just for future reference the patch for using OkHttp instead: |
4.2.7 has been released |
Thanks for the quick fix @uglyog
|
Yes, because if the actual request does not have a content type, it will ignore it (i.e. there is nothing to compare the value to). However, if the actual request does contain a content type for the part, then that should fail if the content type is different. |
BTW, using |
Thanks for the clarification! |
When doing a file upload via
withFileUpload
theContent-Type
header in the individual parts is always set.This causes an issue when it is used for a
multipart/form
request in combination with a HTTP client that never sets the header e.g. khttp.According to the multipart/form-data RFC, the Content-Type is optional. Thus, I would suggest to make it optional here as well.
Example:
See failing test in this repo for an example with pact-jvm and kttps.
The error for the failing test is
body - /: Expected a multipart header ‘Content-Type’, but was missing
.Looking at both requests in their string representation in
MultipartMessageBodyMatcher
while debugging, you can see that the body created by khttp really does not contain theContent-Type
header whereas the one created by pact-jvm does:Actual (created by khttp):
Expected (created by Pact):
The text was updated successfully, but these errors were encountered: