/*
* JBoss, Home of Professional Open Source
* Copyright 2006, JBoss Inc., and others contributors as indicated
* by the @authors tag. All rights reserved.
* See the copyright.txt in the distribution for a
* full listing of individual contributors.
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License, v. 2.1.
* This program is distributed in the hope that it will be useful, but WITHOUT A
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License,
* v.2.1 along with this distribution; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
* (C) 2005-2009, JBoss Inc.
*/
package org.jboss.soa.esb.message;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletResponse;
/**
* Response header.
* <p/>
* Simple name-value pair type that can be attached as a message property and used for
* setting response "headers" (protocol permitting) on the underlying response channel.
*
* @author <a href="mailto:tom.fennelly@jboss.com">tom.fennelly@jboss.com</a>
*/
public class ResponseHeader implements Serializable {
private static final Set<String> BLACKLISTED_PROPERTY_NAMES = new HashSet<String>();
static {
BLACKLISTED_PROPERTY_NAMES.add("content-length"); // hangs the response
BLACKLISTED_PROPERTY_NAMES.add("transfer-encoding"); // hangs the response
BLACKLISTED_PROPERTY_NAMES.add("server"); // creates duplicate header
}
private String name;
private String value;
public ResponseHeader() {}
public ResponseHeader(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
// JBESB-2511
@SuppressWarnings("unchecked")
public void putNameValue(Map map) {
if ( !BLACKLISTED_PROPERTY_NAMES.contains(name.toLowerCase()) ) {
map.put(name, value);
}
}
// JBESB-2511
public void setHeaderNameValue(HttpServletResponse response) {
if ( !BLACKLISTED_PROPERTY_NAMES.contains(name.toLowerCase()) ) {
response.setHeader(name, value);
}
}
// JBESB-2511
public void setPropertyNameThis(Properties properties) {
if ( !BLACKLISTED_PROPERTY_NAMES.contains(name.toLowerCase()) ) {
properties.setProperty(name, this);
}
}
}
|