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 Details

  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in class Encoding
    • encode

      public String encode​(byte[] in) throws EncodingException
      This will split multibyte chars across lines, see 4th ref above
      Specified by:
      encode in class Encoding
      Returns:
      Encoded string.
      Throws:
      UnsupportedOperationException - always
      EncodingException
    • encode

      public String encode​(String str) throws EncodingException
      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 class Encoding
      Parameters:
      str - must start with "field-name: ", must have non-whitespace after that
      Throws:
      EncodingException
      See Also:
      Encoding.encode(byte[])
    • decode

      public void decode​(InputStream in, Buffer bout) throws IOException
      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 class Encoding
      Throws:
      DecodingException
      IOException
      See Also:
      Encoding.decode(byte[], int, int)