-
-
Notifications
You must be signed in to change notification settings - Fork 547
Description
Currently, when an object is sent using the multipart/form-data content type, none of the individual parts have a set content type.
This, however, can be an issue in applications where the server doesn't have a suitable default for form data parts (as is the case in Spring, which considers all parts without a type to be application/octet-stream). When no content type is set and a JSON string representing an object is sent, its content cannot then be deserialized as the server doesn't know that the received content is of the application/json type.
It would therefore be great if this library would tag all parts that have been serialized from an object to a JSON string as application/json. The code that this relates to is shown below:
| const process = (key: string, value: any) => { | |
| if (isString(value) || isBlob(value)) { | |
| formData.append(key, value); | |
| } else { | |
| formData.append(key, JSON.stringify(value)); | |
| } | |
| }; |
It's also important to mention that because of the aforementioned issue with Spring, I have already created a forked version of this library that implements this mechanism, but I have not submitted a PR yet, since I'm not sure if this is desired.