more efficient stream usage in NNTP
authoradam <adam@megacz.com>
Sat, 17 Mar 2007 09:00:23 +0000 (09:00 +0000)
committeradam <adam@megacz.com>
Sat, 17 Mar 2007 09:00:23 +0000 (09:00 +0000)
darcs-hash:20070317090023-5007d-19986e3162f58fcd3dc8f75c3e0431ba3a0cf200.gz

src/org/ibex/mail/NNTP.java

index a0d8dd6..c91c902 100644 (file)
@@ -13,6 +13,7 @@
 package org.ibex.mail;
 import org.ibex.util.*;
 import org.ibex.io.*;
+import org.ibex.net.*;
 import org.ibex.mail.target.*;
 import org.ibex.jinetd.*;
 import java.io.*;
@@ -84,6 +85,7 @@ public class NNTP {
             Mailbox.Iterator it = current.iterator(q);
             if (!it.next()) return null;
             try {
+                // FIXME: UGLY!
                 Message m = body ? it.cur() : Message.newMessage(new Fountain.StringFountain(it.head() + "\r\n"));
                 return new Article(it.nntpNumber(), m);
             } catch (Exception e) { return null; }
@@ -144,7 +146,7 @@ public class NNTP {
             }
             int code = (head && body) ? 220 : head ? 221 : body ? 222 : 223;
             println(code + " " + a.num + " <" + a.message.messageid + "> get ready for some stuff...");
-            if (head) println(a.message.headers.getString());
+            if (head) { a.message.headers.getStream().transcribe(conn); println(); }
             if (head && body) println();
             if (body) {
                 Stream stream = a.message.getBody().getStream();
@@ -295,6 +297,7 @@ public class NNTP {
                     } else {
                      println("340 send the article");
                      StringBuffer buf = new StringBuffer();
+                      // FIXME: streaming?
                      while(true) {
                        String s = conn.readln();
                        if (s == null) throw new RuntimeException("connection closed");