public class Message extends JSReflection {
public final String allHeaders; // pristine headers
- public final Hashtable headers; // hash of headers (not including resent's and traces)
+ public final CaseInsensitiveHash headers; // hash of headers (not including resent's and traces)
public final String body; // entire body
public final int lines; // lines in the body
this.subject = (String)headers.get("Subject");
this.messageid = (String)headers.get("Message-Id");
if (headers.get("Cc") != null) {
+ // FIXME: tokenize better
StringTokenizer st = new StringTokenizer((String)headers.get("Cc"));
this.cc = new Address[st.countTokens()];
for(int i=0; i<this.cc.length; i++) this.cc[i] = new Address(st.nextToken());
traces.copyInto(this.traces = new Trace[traces.size()]);
allHeaders = all.toString();
StringBuffer body = new StringBuffer();
- int lines = 0;
- for(String s = rs.readLine();; s = rs.readLine()) { if (s == null) break; lines++; body.append(s + "\r\n"); }
+ for(String s = rs.readLine();; s = rs.readLine()) {
+ if (s == null) break;
+ lines++;
+ body.append(s); // FIXME: we're assuming all mail messages fit in memory
+ body.append("\r\n");
+ }
this.lines = lines;
this.body = body.toString();
} catch (IOException e) { throw new MailException.IOException(e); }
// use null-sender for error messages (don't send errors to the null addr)
public Message bounce(String reason) { throw new RuntimeException("bounce not implemented"); } // FIXME!
-
- private static class CaseInsensitiveHash extends Hashtable {
- public Object get(Object o) { return (o instanceof String) ? super.get(((String)o).toLowerCase()) : super.get(o); }
- public Object put(Object k, Object v) { throw new Error("you cannot write to a CaseInsensitiveHash"); }
- void add(Object k, Object v) { if (k instanceof String) super.put(((String)k).toLowerCase(), v); else super.put(k, v); }
+
+ public static class CaseInsensitiveHash extends org.ibex.js.JSReflection {
+ private Hashtable stuff = new Hashtable();
+ public Object get(Object o) { return stuff.get(((String)o).toLowerCase()); }
+ void add(Object k, Object v) { if (k instanceof String) stuff.put(((String)k).toLowerCase(), v); else stuff.put(k, v); }
}
}