-
Notifications
You must be signed in to change notification settings - Fork 627
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
Multiline string bodies for multipart form data produce errors on some servers due to unix line ending between body parts #3806
Comments
Thanks for this very detailed description. There is actually no logic in multiline string, characters that are between
We're sending "line1\nline2\r\nline3\n" Concerning multipart, I wasn't aware that message parts should use CRLF separators so, this snippet, from the docs, can be incorrect if the user has no written the right CRLF at the right place:
I think we don't want to put any logic with "classic" multiline stings, so the only way we can support writting a multipart request like this is:
In this case, we process the request body so that we send a correct multipart body. In both case, we need to have a @fabricereix @lepapareil any comment? |
Hi @jcamiel, I tend to prefer the explicit 2nd solution :). |
also in favor if the 2nd solution |
@jcamiel thank you for looking into it (and from the user perspective I wouldn't mind explicitness here, either. Multipart form data is strange enough without additional hidden treatment). Just a side note: on very-verbose mode the current curious side effect is that on a working request the curl command in the verbose output is broken (I think it is split erroneously on a newline and only a part is provided in the output), while on a faulty string input, the curl command appears in the log correctly. Wanted to mention it since on special treatment for the multipart string this problem may remain. |
What is the current bug behavior?
Hurl file with multiline string payload is causing errors due to newline
Depending on the OS hurl creates a curl command such as this:
curl --header 'Content-Type: multipart/form-data; boundary=boundary' --data $'--boundary\nContent-Disposition: form-data; name="record"; filename="blob"\nContent-Type: application/json\n\n{"id":"0"}\n--boundary\nContent-Disposition: form-data; name="document"; filename="blob"\nContent-Type: application/json\n\n{"some":"json"}\n--boundary--\n' 'http://localhost:8888'
This, however, seems to be rejected with an error (such as
MalformedStreamException: Stream ended unexpectedly
) by some servers (such as applications based on SpringBoot and Tomcat) due to unexpected line endings.To me it looks like the produced curl command may not be compliant to RFC 9110:
Steps to reproduce
By the way the exact same thing can be reproduced with the documentation example about multiline string body (once you remove the "" around boundary from the sample, otherwise it will fail anyway on the mentioned systems).
What is the expected correct behavior?
Produce a curl with crlf line endings to make sure that libs such as those in tomcat core can split the parts correctly - I guess? Maybe I am misunderstanding something here completely, because this would be the first time for me that using CRLF would solve, not cause problems.
Execution context
The problem does NOT occur with hurl on windows (due to obvious reasons)
The problem does NOT occur if you convert the hurl file with "unix2dos" command first on unix based systems before executing it.
hurl --version
): 6.0.0Possible fixes
I was not able to manually adapt the hurl file so that I may include correct line endings in the string myself - pointers would be appreciated. Maybe it can simply be solved with correct input - if so, this may be a topic for documentation.
The text was updated successfully, but these errors were encountered: