What is the correct line to use with / plain ContentType?

When the web server claims ContentType: text / plain in the HTTP response, can the client consider the newlines to be "\ n" or "\ r \ n", something else or allow both?

What standards indicate? I am lost and confused among the standards. RFC 2046 appears to define a β€œsimple” subtype, but it refers to RFC 822.

I looked at RFC 822, but am confused that it says that CRLF (\ r \ n) is not explicitly allowed (in the message body), or should CRLF be implicitly allowed, since any ASCII character is legal after an empty string?

RFC 5322 defines an β€œInternet messaging format,” and I'm not sure if this applies to HTTP (seems to be for email), but it specifically states that ONLY CR or LF in the body of the message you should see is CRLF combination ..?

+5
source share
1 answer

RFC 2046 in section 4.1.1 states:

"The canonical form of any subtype" text "MIME MUST always represent a line break as a CRLF sequence. Similarly, any CRLF occurrence in MIME" text "MUST represent a line break. Using CR and LF outside an interrupt line is also prohibited."

To be honest, if you use this for parsing or displaying, I would not rely on it. Most web servers are going to set the content type from the file extension, so any Unix file with the extension .txt will receive a text / simple content type (illegal, as for the above paragraph).

+3
source

All Articles