@Override public void removeHeader(String name) { if (ZPARSER) { zheaders.setHeader(name, (String) null); } else { super.removeHeader(name); } }
@Override public void setHeader(String name, String value) { if (ZPARSER) { zheaders.setHeader(name, value.getBytes()); } else { super.setHeader(name, value); } }
@Override public void load(InputStream is) throws MessagingException { if (ZPARSER) { try { zheaders.appendAll(new com.zimbra.common.mime.MimeHeaderBlock(is)); } catch (IOException ioe) { throw new MessagingException("error reading header block", ioe); } } else { super.load(is); } }
@SuppressWarnings("unchecked") @Override public void addHeader(String name, String value) { if (ZPARSER) { zheaders.addHeader(name, value.getBytes()); } else { if (name != null && RESENT_HEADERS.contains(name.toLowerCase())) { headers.add(0, new InternetHeader(name, value)); } else { super.addHeader(name, value); } } }
@Override public void addHeaderLine(String line) { if (ZPARSER) { if (line == null || line.isEmpty()) { return; } else if (line.charAt(0) == ' ' || line.charAt(0) == '\t') { throw new UnsupportedOperationException("adding continuation lines not yet supported"); } else { Pair<String, byte[]> parsed = parseHeaderLine(line); if (parsed != null) { zheaders.appendHeader(parsed.getFirst(), parsed.getSecond()); } } } else { super.addHeaderLine(line); } }
@Override public String[] getHeader(String name) { if (ZPARSER) { List<com.zimbra.common.mime.MimeHeader> matches = zheaders.getAll(name); if (matches == null || matches.isEmpty()) { return null; } else { int i = 0; String[] values = new String[matches.size()]; for (com.zimbra.common.mime.MimeHeader header : matches) { values[i++] = header.getEncodedValue(defaultCharset); } return values; } } else { return super.getHeader(name); } }