1

I am working on using a framework to send multipart form data containing files. both of them need different content-type. However deep in the library api, i observed that in each body part, along with my content-type, Content-Transfer-Encoding of binary is added.

Hence, i wonder what does it means ? What is the interplay between Content-Type and Content-Transfer-Encoding ?

MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
  • 1
    Content-Transfer-Encoding describes how the data is represented. (Is it raw binary? Is it base64-encoded? quoted-printable?) Content-Type describes how the data is interpreted. (Is it JSON? HTML? A JPG image?) – Raymond Chen Jun 11 '21 at 00:46
  • Ah thanks make sense. Although content-type comes also with Charest, wouldn’t that create a conflict ? – MaatDeamon Jun 11 '21 at 01:03
  • 1
    The content transfer encoding produces bytes. The content type interprets the bytes. Part of interpreting the bytes is knowing what character set they bytes are in. (Are they UTF-8? ISO 8859-1? UTF-16LE?) – Raymond Chen Jun 11 '21 at 04:14
  • I think I get it – MaatDeamon Jun 11 '21 at 08:03
  • in fact both Content-Transfer-Encoding and charset are the same thing technically as charset is just a legacy term, which actually is encoding. See XML which is more up to date: `` . More on this here http://www.grauw.nl/blog/entry/254/ – MaatDeamon Jun 11 '21 at 14:36
  • `The so called conflict that i though would be is clarified here:` "The values "8bit", "7bit", and "binary" all imply that NO encoding has been performed. However, they are potentially useful as indications of the kind of data contained in the object, and therefore of the kind of encoding that might need to be performed for transmission in a given transport system." – MaatDeamon Jun 11 '21 at 14:39
  • "7bit" means that the data is all represented as short lines of US-ASCII data. "8bit" means that the lines are short, but there may be non-ASCII characters (octets with the high-order bit set). "Binary" means that not only may non-ASCII characters be present, but also that the lines are not necessarily short enough for SMTP transport." – MaatDeamon Jun 11 '21 at 14:40
  • https://www.w3.org/Protocols/rfc1341/5_Content-Transfer-Encoding.html – MaatDeamon Jun 11 '21 at 14:40
  • or the newest version: "The Content-Transfer-Encoding values "7bit", "8bit", and "binary" all mean that the identity (i.e. NO) encoding transformation has been performed. As such, they serve simply as indicators of the domain of the body data, and provide useful information about the sort of encoding that might be needed for transmission in a given transport system." found here : https://datatracker.ietf.org/doc/html/rfc2045#section-6 – MaatDeamon Jun 11 '21 at 14:47

0 Answers0