android-upload-service
android-upload-service copied to clipboard
Add contentType to addParameter
Describe the solution you'd like There are times when we want to declare the contentType of a parameter, as in this case: https://stackoverflow.com/a/60968768/6015400
Currently there is no way to declare the contentType of the parameter in question, it can only be done for the file
Are you willing to implement it and maintain it?
- [ ] Yes
- [ ] Can implement it with a Pull Request, but not maintain it
- [X] No
Hi @vallemar from a protocol standpoint, key-values parameters passed in multipart form data are always strings. If the server requires the values to be something specific, it's weak to depend on the client. So, for the example you mentioned, on the server side it's possible to simply check if the string value is a json and return a 4xx validation error to the client if it's not. The server should do that validation in any case, whether you specify content type or not from the client.
Hi @gotev , yes, I understand the point, but always sending strings will be the default value, not always, frameworks such as axios, spring boot or the postman tool allow it so I understand that it will be an additional configuration within the protocol (I am not an expert). Thank you very much for your prompt response
Sure, many tools allows it, but it's still an edge case and may cause problems with some servers, as it's not common standard. The library aims at providing the best compatibility with all kind of servers. For example, OkHttp doesn't allow this even in latest 5.x versions, as it follows strictly RFC 2387.
My 2 cents here if you're in an edge case like this: why a server would want to force the clients to do that? Specifying content types explicitly like that deviates from the standard, it increases payload size and does not add anything from a validation standpoint, as the server still gets form data params as raw url encoded input strings when reading from the stream.
Closing this issue. Currently this is not going to be implemented in the library.