HTTP Client and Content-Type: multipart/form-data and Content-Transfer-Encoding: base64
已回答
Hi community,
I’m working on a multipart/form-data POST request using the IntelliJ HTTP Client. My goal is to send a file with the Content-Transfer-Encoding: base64 header.
Here’s how it works successfully with curl:
curl --trace-ascii trace.log -H "Content-Type: multipart/form-data" -F "file=@archive.zip;encoder=base64;type=application/x-zip-compressed" "http://127.0.0.1/upload/"This generates the following request:
POST /upload/ HTTP/1.1
Host: 127.0.0.1
User-Agent: curl/8.9.1
Accept: */*
Content-Length: 640035
Content-Type: multipart/form-data; boundary=--------------------
----iE11EjDWsC9QGLjXu5QlpN
--------------------------iE11EjDWsC9QGLjXu5QlpN
Content-Disposition: form-data; name="file"; filename="archive.zip"
Content-Type: application/x-zip-compressed
Content-Transfer-Encoding: base64
UEsDBAoAAAgAALV+eVkAAAAAAAAAAAAAAAAnAAAAa2F0YWxvZy1jb250ZW50LTAuMC4wLVNOQVBT
...
NTgvY2F0YWxvZ19WZXJnYWJldmVyZmFocmVuLnhtbFBLBQYAAAAAGAIYAgz4AAAU
KgYAAAA=
--------------------------iE11EjDWsC9QGLjXu5QlpN--
With the IntelliJ HTTP Client, I tried this:
POST http://127.0.0.1/upload/ HTTP/1.1
Content-Type: multipart/form-data; boundary=boundary
--boundary
Content-Disposition: form-data; name="file"; filename="archive.zip"
Content-Type: application/x-zip-compressed
Content-Transfer-Encoding: base64
< archive.zip
--boundary--The Issue:
On the server side, I see this request from the IntelliJ HTTP Client:
user-agent=[IntelliJ HTTP Client/IntelliJ IDEA 2024.3],
accept-encoding=[br, deflate, gzip, x-gzip], accept=[*/*],
host=[localhost],
content-type=[multipart/form-data; boundary=6e61e87fb534e2fc],
content-length=[467759]
content-disposition: form-data; name="file"; filename="archive.zip"
content-length: 467510
content-type: application/x-zip-compressed
content-transfer-encoding: binaryThe Content-Transfer-Encoding header is rewritten as binary, which doesn’t align with my expectation or match the behavior of curl.
My Expectations:
- Ideally, the IntelliJ HTTP Client should support encoding the file as Base64 (like
curldoes withencoder=base64). - At the very least, the HTTP Client should respect and pass through the
Content-Transfer-Encoding: base64header as specified.
Question:
Does anyone know how to achieve Base64 encoding for multipart file uploads in IntelliJ HTTP Client? Is there a way to prevent it from rewriting the Content-Transfer-Encoding header?
Any suggestions or insights would be greatly appreciated!
1 条评论
排序方式
日期
投票数
Hi Uwe, I recommend you to submit an issue report to https://youtrack.jetbrains.com/issues?q=%23%7BIntelliJ%20IDEA%7D%20
请先登录再写评论。