- public Headers remove(String key) { return set(key, null); /* FIXME */ }
-
- public static class Original extends Headers {
- private final Hash head = new Hash();
- public int lines;
- public final boolean mime;
- private String raw;
- private Fountain fountain;
-
- //public String getString() { return raw; }
-
- public Stream getStream() { return fountain.getStream(); }
- public long getLength() { return fountain.getLength(); }
- public int getNumLines() { return fountain.getNumLines(); }
-
- public JS get(JS s) throws JSExn { return JSU.S(get(JSU.toString(s).toLowerCase())); }
-
- public String[] getHeaderNames() { return (String[])head.dumpkeys(new String[head.size()]); }
- public String get(String s) { return (String)head.get(s.toLowerCase()); }
-
- public Original(Stream stream) throws Malformed { this(stream, false); }
- public Original(Stream stream, boolean assumeMime) throws Malformed {
- StringBuffer all = new StringBuffer();
- String key = null;
- int lines = 0;
- for(String s = stream.readln(); s != null && !s.equals(""); s = stream.readln()) {
- all.append(s);
- all.append("\r\n");
- lines++;
- if (Character.isSpace(s.charAt(0))) {
- if (key == null) throw new Malformed("Message began with a blank line; no headers");
- head.put(key, head.get(key) + " " + s.trim());
- continue;
- }
- if (s.indexOf(':') == -1) throw new Malformed("Header line does not contain colon: " + s);
- key = s.substring(0, s.indexOf(':')).toLowerCase();
- for(int i=0; i<key.length(); i++)
- if (key.charAt(i) < 33 || key.charAt(i) > 126) {
- Log.error(null,all);
- throw new Malformed("Header key \""+key+"\" contains invalid character \"" +
- key.charAt(i) + "\" (0x"+Integer.toString(key.charAt(i), 16) +")");
- }
- String val = s.substring(s.indexOf(':') + 1).trim();
- if (get(key) != null) val = get(key) + " " + val; // just append it to the previous one;
- head.put(key, val);
+
+ private Entry[] updateHeaders(String[] keyval) {
+ ArrayList<Entry> entries = new ArrayList<Entry>();
+ for(int i=0; i<this.entries.length; i++)
+ entries.add(this.entries[i]);
+ for(int i=0; i<keyval.length; i+=2) {
+ for(int j=0; j<entries.size(); j++) {
+ Entry e = entries.get(j);
+ if (!e.key.toLowerCase().equals(keyval[i])) continue;
+ if (keyval[i+1]==null)
+ entries.remove(j);
+ else
+ entries.set(j, new Entry(keyval[i], keyval[i+1]+"\r\n"));
+ break;