-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Content-Type Header for Multipart-Requests should be checked case-insensitive #2707
Conversation
Hello @mufasa1976 , can you fix the pipeline, so we can review it. Thanks! |
but without knowing what to fix because on my local machine there will be no error
I've tried to fix the formatting Issues on On my local Machine (Ubuntu 22.04.4 LTS) the Task Thank you very much |
Can you give it a try running |
I've tried but there were no File changes after ./gradlew :spotlessApply |
@@ -289,7 +289,7 @@ public Collection<Part> getParts() { | |||
@Override | |||
public boolean isMultipart() { | |||
String header = getHeader("Content-Type"); | |||
return (header != null && header.contains("multipart/")); | |||
return (header != null && header.matches("(?i)^multipart/.*")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally speaking this is right and improve the current behaviour(not only for case insensitive aspect), but I would like to support also potential white spaces at the beginning. I suggest to trim the String or add it in the regular expression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I've updated the regular Expression to ignore any whitespace character at the beginning of content-type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, one. Can you keep both, with and without spaces?😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regular Expression already handles both cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or did you mean the Test Case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I meant the test case,hehe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, i've adapted the Test so that the same Content will be sent twice. One time with leading spaces before the content-type and one time without leading spaces
Nice work! Just one last change and it's done; keep two independent methods, one without spaces( It sounds stupid, but that makes clear and easier to spot what has gone wrong in the future. |
Regarding the formatting, this should work:
However, if this doesn't work, let me know. |
Ok, I have splitted one test into 2 tests with the appropriate Method-Names |
Thank you very much. Indead this had helped! |
Merged it! And sorry for the formatting, I believe the fix is just run those comments I mentioned, but we want to ensure and will document it. Thanks for your contribution |
References
When testing SOAP-Requests with MTOM enabled the Standard SAAJ Implementation sends a HTTP-Header
Content-Type: Multipart/Related; boundary=...
. This leads to a Failure on Wiremock Multipart Behaviour because it only has checked against lowercasedmultipart/
.Instead it checks against a case-insensitive Regular-Expression
^multipart/.*
.Can this be also merged to the Java-8 related Versions?
Submitter checklist
#help-contributing
or a project-specific channel like#wiremock-java