/** * Add a header to this message. If the key is found in the headers of this message, the value * is appended to the previous value found and separated by a space. A key of null will not be * added. If value is null, previous entries of the matching key will be removed. * * @param key * The key of the header. * @param value * The value of the header. */ public void addHeader(String key, String value) { if (headers == null || headers.get(key) == null) { setHeader(key, value); } else if (key != null && value != null) { String prevVal = headers.get(key); prevVal += " " + value; headers.put(key, prevVal); } else if (value == null) { removeHeader(key); } }
/** * Add a header to this message. If the key is found in the headers of this message, the value * is appended to the previous value found and separated by a space. A key of null will not be * added. If value is null, previous entries of the matching key will be removed. * * @param key * The key of the header. * @param value * The value of the header. */ public void addHeader(String key, String value) { if (headers == null || headers.get(key) == null) { setHeader(key, value); } else if (key != null && value != null) { String prevVal = headers.get(key); prevVal += " " + value; headers.put(key, prevVal); } else if (value == null) { removeHeader(key); } }