Commits

Anonymous committed 8453414

Reengineer the MIME entity parser.

  • Participants
  • Parent commits 37aa2e6

Comments (0)

Files changed (4)

 
 + (unimplemented): Many optional features.
 
++ (Mime_stream): Inherit from Iom_octet_stream.parse and emit and provide
+    convenience factories for isimplex, osimplex and duplex reactors that have
+    octet stream plugs on one end and mime stream jacks on the other.
+    
+    A mime stream carries exactly one event, delivered when the top-level
+    headers are presented.  The event includes a subclass of the mime entity
+    headers object and either an octet stream for the body or a stream of mime
+    entity streams for multipart messages.
+
 # End of open issues

mime/mime_entity.ml

     cd_parameters: string Mime_atom.Map.t;
 }
 
-class type headers =
-    object
-        method content_type: ct_t option
-        method content_disposition: cd_t option
-        method content_transfer_encoding: cte_t option
-        method content_description: string option
-        method content_length: int64 option
-        method content_id: (string * string) option
-        method unstructured: (string * string) list
-    end
+class type headers = object
+    method content_type: ct_t option
+    method content_disposition: cd_t option
+    method content_transfer_encoding: cte_t option
+    method content_description: string option
+    method content_length: int64 option
+    method content_id: (string * string) option
+    method unstructured: (string * string) list
+end
 
 module S = struct
     let content_type = "Content-Type"

mime/mime_entity.mli

     cd_parameters: string Mime_atom.Map.t;
 }
 
-class type headers =
-    object
-        method content_type: ct_t option
-        method content_disposition: cd_t option
-        method content_transfer_encoding: cte_t option
-        method content_description: string option
-        method content_length: int64 option
-        method content_id: (string * string) option
-        method unstructured: (string * string) list
-    end
+class type headers = object
+    method content_type: ct_t option
+    method content_disposition: cd_t option
+    method content_transfer_encoding: cte_t option
+    method content_description: string option
+    method content_length: int64 option
+    method content_id: (string * string) option
+    method unstructured: (string * string) list
+end
 
-class headers_parser:
-    (string * char Cf_seq.t) list ->
-    object
-        inherit headers
-        method force: unit
-    end
+class headers_parser: (string * char Cf_seq.t) list -> object
+    inherit headers
+    method force: unit
+end
 
 val parse_headers: Cf_message.t -> headers_parser * Cf_message.t
 

mime/mime_stream.ml

 
 exception Header_too_long
 
+type 'headers r_event =
+    | R_event of 'headers * r_body
+    constraint 'headers = #Mime_entity.headers
+and r_body =
+    | R_body of Iom_octet_stream.fragment Iom_gadget.rx
+    | R_part of (Iom_stream.more * Mime_entity.headers r_event) Iom_gadget.rx
+    
+class ['headers] parse flowTx readRx mimeTx = object
+    inherit [Iom_octet_stream.fragment, 'headers r_event]
+        Iom_octet_stream.parse flowTx readRx mimeTx as super
+        
+    method lex (_ : Cf_message.t) (_ : char Cf_seq.t) =
+        (None : (('headers r_event * int) * char Cf_seq.t) option)
+    
+    (* what about flowRx? probably no need (lower levels do that) *)
+end
+
+type 'headers w_event =
+    | W_event of 'headers * w_body
+    constraint 'headers = #Mime_entity.headers
+and w_body =
+    | W_body of Iom_octet_stream.fragment Iom_gadget.tx
+    | W_part of (Iom_stream.more * Mime_entity.headers w_event) Iom_gadget.tx
+
 (*---------------------------------------------------------------------------*
 let rec mqPush n q = function
     | (_, _, len as hd) :: tl -> mqPush (n + len) (Cf_deque.A.push hd q) tl