Closed c4710n closed 2 years ago
Hola, Thanks for providing this cool package.
Recently, I met a possible issue about multipart data.
As describe in doc, I create a request like this:
** Upload two files to user storage post /{{(verb-var user-id)}}/upload Content-Type: multipart/form-data; boundary={{(verb-boundary)}} {{(verb-part "file" "file1.txt")}} Content-Type: text/plain {{(verb-read-file "documents/file1.txt")}} {{(verb-part "file" "file2.xml")}} Content-Type: application/xml {{(verb-read-file "documents/file2.xml")}} {{(verb-part)}}
But, the remote server complained that the request is not standard.
Then, I found:
\r\n
verb
\n
Some servers can handle the non-standard format, some can't.
A possible resolution - insert \r manually:
\r
This can be done in Emacs by using C-q C-m.
C-q C-m
** Upload two files to user storage post /{{(verb-var user-id)}}/upload Content-Type: multipart/form-data; boundary={{(verb-boundary)}} {{(verb-part "file" "file1.txt")}}^M Content-Type: text/plain^M ^M {{(verb-read-file "documents/file1.txt")}}^M {{(verb-part "file" "file2.xml")}}^M Content-Type: application/xml^M ^M {{(verb-read-file "documents/file2.xml")}}^M {{(verb-part)}}^M
It seems to work fine. But, verb-part blocks me.
verb-part
In the implementation of verb-part, \n is used: https://github.com/federicotdn/verb/blob/f9ea5780ec65e6f30451514b72ce99619dd8457f/verb.el#L2227
I think it should be \r\n for more standard request.
I have rewrite this function on my local machine.
I think my solution is clumsy. Maybe we can have a better solution, for example:
Fixed in main - thanks for reporting this 👍🏻 .
main
Hola, Thanks for providing this cool package.
Recently, I met a possible issue about multipart data.
As describe in doc, I create a request like this:
But, the remote server complained that the request is not standard.
Then, I found:
\r\n
).verb
sends above request body which is using LF(\n
) as the newline char.Some servers can handle the non-standard format, some can't.
A possible resolution - insert
\r
manually:It seems to work fine. But,
verb-part
blocks me.In the implementation of
verb-part
,\n
is used: https://github.com/federicotdn/verb/blob/f9ea5780ec65e6f30451514b72ce99619dd8457f/verb.el#L2227I think it should be
\r\n
for more standard request.I think my solution is clumsy. Maybe we can have a better solution, for example:
\n
with\r\n
before sending request.