Author: tterm
Date: Wed May 2 10:07:28 2007
New Revision: 534549
URL: http://svn.apache.org/viewvc?view=rev&rev=534549
Log:
SM-795 HTTP headers attached as properties may cause requests to fail
Modified:
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java
Modified:
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java?view=diff&rev=534549&r1=534548&r2=534549
==============================================================================
---
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java
(original)
+++
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfiguration.java
Wed May 2 10:07:28 2007
@@ -119,6 +119,13 @@
private int proxyPort;
/**
+ * This field is used to decide if the http prover processor can copy the
http headers from the http response
+ * into the exchange as property. Be careful if the headers will be used
for a new http reuquest, it leads to an
+ * error.
+ */
+ private boolean wantHeadersFromHttpIntoExchange;
+
+ /**
* @return Returns the rootDir.
* @org.apache.xbean.Property hidden="true"
*/
@@ -361,6 +368,22 @@
this.proxyPort = proxyPort;
save();
}
+
+ /**
+ *
+ * @return Returns the it the http headers will be copied into the exchange
+ */
+ public boolean isWantHeadersFromHttpIntoExchange() {
+ return wantHeadersFromHttpIntoExchange;
+ }
+
+ /**
+ *
+ * @param wantHeadersFromHttpIntoExchange true if the headers should be
copied into the exchange
+ */
+ public void setWantHeadersFromHttpIntoExchange(boolean
wantHeadersFromHttpIntoExchange) {
+ this.wantHeadersFromHttpIntoExchange = wantHeadersFromHttpIntoExchange;
+ }
public void save() {
setProperty(componentName + ".jettyThreadPoolSize",
Integer.toString(jettyThreadPoolSize));
@@ -376,6 +399,7 @@
setProperty(componentName + ".retryCount",
Integer.toString(retryCount));
setProperty(componentName + ".proxyHost", proxyHost);
setProperty(componentName + ".proxyPort", Integer.toString(proxyPort));
+ setProperty(componentName + ".wantHeadersFromHttpIntoExchange",
Boolean.toString(wantHeadersFromHttpIntoExchange));
if (rootDir != null) {
File f = new File(rootDir, CONFIG_FILE);
try {
@@ -459,6 +483,10 @@
}
if (properties.getProperty(componentName + ".proxyPort") != null) {
proxyPort = Integer.parseInt(properties.getProperty(componentName
+ ".proxyPort"));
+ }
+ if (properties.getProperty(componentName +
".wantHeadersFromHttpIntoExchange") != null) {
+ wantHeadersFromHttpIntoExchange =
+ Boolean.valueOf(properties.getProperty(componentName +
".wantHeadersFromHttpIntoExchange")).booleanValue();
}
return true;
}
Modified:
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java?view=diff&rev=534549&r1=534548&r2=534549
==============================================================================
---
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
(original)
+++
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/HttpConfigurationMBean.java
Wed May 2 10:07:28 2007
@@ -70,4 +70,8 @@
public void setProxyPort(int name);
+ boolean isWantHeadersFromHttpIntoExchange();
+
+ void setWantHeadersFromHttpIntoExchange(boolean
wantHeadersFromHttpIntoExchange);
+
}
Modified:
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?view=diff&rev=534549&r1=534548&r2=534549
==============================================================================
---
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
(original)
+++
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
Wed May 2 10:07:28 2007
@@ -39,11 +39,7 @@
import org.apache.servicemix.JbiConstants;
import org.apache.servicemix.common.BaseLifeCycle;
import org.apache.servicemix.common.ExchangeProcessor;
-import org.apache.servicemix.http.ContextManager;
-import org.apache.servicemix.http.HttpComponent;
-import org.apache.servicemix.http.HttpEndpoint;
-import org.apache.servicemix.http.HttpProcessor;
-import org.apache.servicemix.http.SslParameters;
+import org.apache.servicemix.http.*;
import org.apache.servicemix.http.jetty.JaasJettyPrincipal;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.soap.Context;
@@ -81,7 +77,7 @@
this.soapHelper = new SoapHelper(endpoint);
this.locks = new ConcurrentHashMap();
this.exchanges = new ConcurrentHashMap();
- this.suspentionTime = ((HttpComponent)
endpoint.getServiceUnit().getComponent()).getConfiguration().getConsumerProcessorSuspendTime();
+ this.suspentionTime =
getConfiguration().getConsumerProcessorSuspendTime();
}
public SslParameters getSsl() {
@@ -178,7 +174,9 @@
request.setAttribute(Context.class.getName(), context);
exchange = soapHelper.onReceive(context);
NormalizedMessage inMessage = exchange.getMessage("in");
- inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS,
getHeaders(request));
+ if (getConfiguration().isWantHeadersFromHttpIntoExchange()) {
+ inMessage.setProperty(JbiConstants.PROTOCOL_HEADERS,
getHeaders(request));
+ }
locks.put(exchange.getExchangeId(), cont);
request.setAttribute(MessageExchange.class.getName(),
exchange.getExchangeId());
synchronized (cont) {
@@ -291,6 +289,11 @@
response.setStatus(200);
response.setContentType("text/xml");
new SourceTransformer().toResult(new DOMSource(node), new
StreamResult(response.getOutputStream()));
+ }
+
+ protected HttpConfiguration getConfiguration() {
+ HttpComponent comp = (HttpComponent)
endpoint.getServiceUnit().getComponent();
+ return comp.getConfiguration();
}
}
Modified:
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java?view=diff&rev=534549&r1=534548&r2=534549
==============================================================================
---
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java
(original)
+++
incubator/servicemix/branches/servicemix-3.1/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ProviderProcessor.java
Wed May 2 10:07:28 2007
@@ -199,7 +199,9 @@
contentType != null ?
contentType.getValue() : null);
context.setOutMessage(soapMessage);
soapHelper.onAnswer(context);
- msg.setProperty(JbiConstants.PROTOCOL_HEADERS,
getHeaders(method));
+ if (getConfiguration().isWantHeadersFromHttpIntoExchange()) {
+ msg.setProperty(JbiConstants.PROTOCOL_HEADERS,
getHeaders(method));
+ }
soapHelper.getJBIMarshaler().toNMS(msg, soapMessage);
((InOut) exchange).setOutMessage(msg);
if (txSync) {
@@ -220,7 +222,9 @@
method.getResponseHeader(Constants.HEADER_CONTENT_TYPE).getValue());
context.setOutMessage(soapMessage);
soapHelper.onAnswer(context);
- msg.setProperty(JbiConstants.PROTOCOL_HEADERS,
getHeaders(method));
+ if
(getConfiguration().isWantHeadersFromHttpIntoExchange()) {
+ msg.setProperty(JbiConstants.PROTOCOL_HEADERS,
getHeaders(method));
+ }
soapHelper.getJBIMarshaler().toNMS(msg, soapMessage);
((InOptionalOut) exchange).setOutMessage(msg);
if (txSync) {