Commits

Anonymous committed 8bcc137

Rename basic_emit_adapter#emit to to_message, and implement emit as a
method to emit headers followed by the blank line separator.

  • Participants
  • Parent commits 58bb8c8

Comments (0)

Files changed (4)

mime/mime_entity.ml

     method private emit_unstructured: Format.formatter -> unit
     method private emit_headers: Format.formatter -> unit
     
-    method emit: Cf_message.t
+    method emit: Format.formatter -> unit
+    method to_message: Cf_message.t
 end
 
 class basic_emit_adapter =
             self#emit_structured pp;
             self#emit_unstructured pp
 
-        method emit =
+        method emit pp =
+            self#emit_headers pp;
+            Format.pp_print_newline pp ()
+
+        method to_message =
             let b = Buffer.create 256 in
-            let pp = L.formatter b in
-            self#emit_headers pp;
-            Format.pp_print_newline pp ();
+            self#emit (L.formatter b);
             let str = Buffer.contents b in
             let len = String.length str in
             [ str, 0, len ]

mime/mime_entity.mli

     method private emit_unstructured: Format.formatter -> unit
     method private emit_headers: Format.formatter -> unit
     
-    method emit: Cf_message.t
+    method emit: Format.formatter -> unit
+    method to_message: Cf_message.t
 end
 
 class basic_emit_adapter:

mime/mime_stream.ml

             [ m ], Cf_message.length data
         
         method push_event (headers, bodyRx) =
-            self#push_octets Iom_stream.More headers#emit >>=
+            self#push_octets Iom_stream.More headers#to_message >>=
                 fun (consume, buffer, mark) ->
             Cf_cmonad.return {<
                 consume_ = consume; buffer_ = buffer; mark_ = mark;
     Iom_gadget.start begin
         Iom_gadget.guard begin
             eventRx#get begin fun (headers, fragmentRx) ->
-                let m = headers#emit in
+                let m = headers#to_message in
                 let fragment =
                     new Iom_octet_stream.fragment Iom_stream.More m
                 in
     
     let test () =
         let e = new message_emit_adapter ~cte ~ct ~cid ~cl [] in
-        let m = e#emit @ (Cf_message.create body) in
+        let m = e#to_message @ (Cf_message.create body) in
         let h' = Cf_message.contents m in
         if h' <> h then jout#fail "emit error [%s][%s]" h' h;
         let p, body' = scan_message_headers (new message_scan_adapter) m in