2020.22080 - Win 10 - WebClient DAT missing Content-Type with PUT method


I’m having some issues with file upload using the Web Client DAT. I’m using the request(url, method, uploadFile) method in Python with a PUT request method.

When trying to digest the request with Express.js / Formidable, it gives an error:

Error: bad content-type header, no content-type

Since I believe the Content-Type should be multipart/form-data for file upload, I can pass that manualy in the headers for the request method. However then I get the following error from Formidable:

Error: bad content-type header, no multipart boundary

I believe the boundary should be set by the web client when making the request and match with a value in (or size of?) the request body, which is the file contents.

When using POST for example, I do see that the Web Client DAT sets the Content-Type to application/x-www-form-urlencoded. However that doesn’t work with file upload.

Could the missing header with PUT be an error in the client, or am I missing something?


1 Like

To my understanding, if you’re setting the content-type to multipart/* then you should also be supplying a boundary parameter following syntax defined here: https://www.ietf.org/rfc/rfc2046.txt in section 5.1.1.

For example:

Content-Type: multipart/mixed; boundary=“gc0pJq0M:08jU534c0p”

Hi @eric.b,

Correct, the boundary must be set in the header, which is causing the error. However this boundary also needs to occur in the body, which is the uploaded file, as it states in that document:

The body must then contain one or more body parts, each preceded by a boundary delimiter line, and the last one followed by a closing boundary delimiter line.

With the request(url, method, uploadFile) method of the Web Client DAT, you can just supply the filename and not create the request body, which is done by the DAT internally.

I think it would make most sense if the DAT would automatically set the Content-Type header to multipart/form-data when the uploadFile parameter is passed. When it creates the request body it should put the file contents between the boundary delimiter lines and add the boundary to the Content-Type header.

I should have mentioned this earlier, but the current implementation of upload file isn’t multipart or MIME, rather it sends the contents of the file chunked to the server.

I will add this as an RFE though.

Ok, good to know. Thanks!