What is the main differents between UrlEncodedFormEntity and MultipartEntity? When should I use UrlEncodedFormEntity and when should I use MultipartEntity?
Asked
Active
Viewed 352 times
1
-
1See [here](http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2) - _"The content type "application/x-www-form-urlencoded" is inefficient for sending large quantities of binary data or text containing non-ASCII characters. The content type "multipart/form-data" should be used for submitting forms that contain files, non-ASCII data, and binary data."_ – Paul Samsotha Jul 21 '15 at 08:53
-
does that mean that UrlEncodedFormEntitycan always be replaced by MultipartEntity? Is there any case, where to say: hmm its better to use UrlEncodedFormEntity than MultipartEntity? – Max_Salah Jul 21 '15 at 09:26
-
1I guess I misred the question. I was under the assumption you understood the difference in media types. These are two completely different media types with different formats. Your question seems to be related to client side classes, that I believe are from the apache client libs. To answer your question, no you cannot replace one with the other. You need to determine what type the server will will accept, then you use that type. I guess my above comment is more server related, as to when you should use form-encoded vs multipart. But as a client, you can't choose. it's up to the server – Paul Samsotha Jul 21 '15 at 09:32
-
1The link I provided is a complete breakdown of the different form types. It should give you a better general understanding of both media types. As for the class relations, `UrlEncodedFormEntity` is used for `application/x-www-form-urlencoded`, while `MultipartEntity` is used for `multipart/xxx`. – Paul Samsotha Jul 21 '15 at 09:34