purebred-mua / purebred-email

A fast email parsing library implemented in Haskell
https://hackage.haskell.org/package/purebred-email
GNU Affero General Public License v3.0
23 stars 4 forks source link

support message types with no body or optional body #45

Closed frasertweedale closed 4 years ago

frasertweedale commented 4 years ago
e8488e0 (Fraser Tweedale, 5 minutes ago)
   support parsing messages with no body

   RFC 5322 and its predecessors define message as:

      message         =   (fields / obs-fields)
                         [CRLF body]

   The body is optional, and there is syntactic and semantic difference 
   between an empty body and a missing body.  Enhance purebred-email to 
   support parsing message types that do not have a body, or have an optional
   body.

   Also add a default implementation for EqMessage:

     default eqMessage :: (Eq a) => Message s a -> Message s a -> Bool

   Fixes: https://github.com/purebred-mua/purebred-email/issues/35

89c0c3a (Fraser Tweedale, 2 hours ago)
   generalise buildMessage and renderMessage

   buildMessage and renderMessage were specialised to MIME payloads. But to
   support other payload types using RFC 5322, generalise these methods over a
   new type class 'RenderMessage a'.  The class does admit message types
   without bodies so the rendering part of 
   https://github.com/purebred-mua/purebred-email/issues/35 is now done.

   Also change the type of 'renderMessage' to return /lazy/ ByteString. Strict
   ByteString is almost always *not* suitable.
romanofski commented 4 years ago

I like it. I'm especially keen to reflect this change in the UI of purebred. I think that would be spiffy.

frasertweedale commented 4 years ago

@romanofski there is nothing to do for purebred; we always try and parse MIME (which falls back to a plain ByteString Part if there is no MIME-Version header. In practice I doubt we'll need to handle bodyless messages in Purebred.