Package i2p.susi.webmail.encoding
Class HeaderLine
java.lang.Object
i2p.susi.webmail.encoding.Encoding
i2p.susi.webmail.encoding.HeaderLine
public class HeaderLine extends Encoding
Ref:
http://en.wikipedia.org/wiki/MIME#Encoded-Word
http://tools.ietf.org/html/rfc2047
https://jeffreystedfast.blogspot.com/2013/09/time-for-rant-on-mime-parsers.html
https://jeffreystedfast.blogspot.com/2013/08/why-decoding-rfc2047-encoded-headers-is.html
- Author:
- susi
-
Field Summary
-
Constructor Summary
Constructors Constructor Description HeaderLine()
-
Method Summary
Modifier and Type Method Description void
decode(InputStream in, Buffer bout)
Decode all the header lines, up through \r\n\r\n, and puts them in the ReadBuffer, including the \r\n\r\nString
encode(byte[] in)
This will split multibyte chars across lines, see 4th ref aboveString
encode(String str)
Encode a single header line ONLY.String
getName()
-
Field Details
-
NAME
- See Also:
- Constant Field Values
-
-
Constructor Details
-
HeaderLine
public HeaderLine()
-
-
Method Details
-
getName
-
encode
This will split multibyte chars across lines, see 4th ref above- Specified by:
encode
in classEncoding
- Returns:
- Encoded string.
- Throws:
UnsupportedOperationException
- alwaysEncodingException
-
encode
Encode a single header line ONLY. Do NOT include the \r\n. Returns a string of one or more lines including the trailing \r\n. Field-name will not be encoded, must be less than 62 chars. The fieldBody is treated as "unstructured text", which is suitable only for the field names "Subject" and "Comments". We do NOT tokenize into structured fields. To make things easy, we either encode the whole field body as RFC 2047, or don't encode at all. If it's too long for a single line, we encode it, even if we didn't otherwise have to. We don't do quoted-string. This will not split multibyte chars, including supplementary chars, across lines. TODO this will not work for quoting structured text such as recipient names on the "To" and "Cc" lines.- Overrides:
encode
in classEncoding
- Parameters:
str
- must start with "field-name: ", must have non-whitespace after that- Throws:
EncodingException
- See Also:
Encoding.encode(byte[])
-
decode
Decode all the header lines, up through \r\n\r\n, and puts them in the ReadBuffer, including the \r\n\r\n- Specified by:
decode
in classEncoding
- Throws:
DecodingException
IOException
- See Also:
Encoding.decode(byte[], int, int)
-