Project: mule
Issue MULE-8181: Problem sending outbound attachments in HTTP requester
When sending a multipart request, the requester assumes that each part is a file, and adds the corresponding headers (filename attribute at the beginning of the part, transfer-encoding: binary, etc). This makes the request to be invalid in some cases. Use case to test: upload a file to Box. Example test (replace the dev token and the parent folder id): The requester sends a multipart request with the following format. POST /api/2.0/files/content HTTP/1.1 Host: localhost:8082 Authorization: Bearer xxxxxxxxxx MULE_ENCODING: UTF-8 Connection: keep-alive Accept: */* User-Agent: NING/1.0 Content-Type: multipart/form-data; boundary=Tdv259AB4D2JOrezEkOphg5Ikreks3mIO2jC Content-Length: 463 --Tdv259AB4D2JOrezEkOphg5Ikreks3mIO2jC Content-Disposition: form-data; name="attributes"; filename="attributes" Content-Type: application/json Content-Transfer-Encoding: binary {"name":"test.txt", "parent":{"id":"12345678"}} --Tdv259AB4D2JOrezEkOphg5Ikreks3mIO2jC Content-Disposition: form-data; name="test.txt"; filename="test.txt" Content-Type: text/plain Content-Transfer-Encoding: binary Test content --Tdv259AB4D2JOrezEkOphg5Ikreks3mIO2jC-- The problem is the "attributes" part, which is sent as a file part. It shouldn't contain the filename attribute, and the transfer encoding shouldn't be binary. Postman just sends the following, and it works correctly: Content-Disposition: form-data; name="attributes" {"name":"test.txt", "parent":{"id":"12345678"}}
Story points: 8