Delphi 10 TRestClient MIME boundary issue

元气小坏坏 提交于 2020-06-16 04:54:47

问题


I am trying to consume a REST service using TRestClient but I believe there is an issue with the boundary string for multipart content.

I am capturing the body of the request I am sending, and this is the content type header:

Content-Type: multipart/form-data; boundary=-------Embt-Boundary--07CC944C29DA577E

Then, this is the first section of the multipart form:

-----------Embt-Boundary--07CC944C29DA577E
Content-Disposition: form-data; name="file"; filename="ce.csv"
Content-Type: text/csv

And this is how it ends:

---------Embt-Boundary--07CC944C29DA577E--

I don't think this is an issue on the server, as even my proxy is not able to parse the body:

When I compare this same request vs postman, I notice that the starting and ending boundaries do not match!

Starting: -----------Embt-Boundary--07CC944C29DA577E
Ending:   ---------Embt-Boundary--07CC944C29DA577E-- 

I found that the boundary generation is done in TMultipartFormData.GenerateBoundary() from System.Net.Mime:

When checking the starting and ending boundaries from postman, they match, so I am almost sure this is the issue. I don't think it is related to my code, but let me know if you need it.

来源:https://stackoverflow.com/questions/60961222/delphi-10-trestclient-mime-boundary-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!