Author: ningjiang
Date: Wed Sep 5 07:32:56 2012
New Revision: 1381042
URL: http://svn.apache.org/viewvc?rev=1381042&view=rev
Log:
Upgarde the http client of camel-http4 to 4.2.x
Modified:
camel/trunk/components/camel-http4/pom.xml
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
Modified: camel/trunk/components/camel-http4/pom.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/pom.xml?rev=1381042&r1=1381041&r2=1381042&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/pom.xml (original)
+++ camel/trunk/components/camel-http4/pom.xml Wed Sep 5 07:32:56 2012
@@ -32,9 +32,9 @@
<description>Camel HTTP (Apache HttpClient 4.x) support</description>
<properties>
- <!-- 4.1 should still be supported -->
+ <!-- Now we move to the 4.2 -->
<camel.osgi.import.before.defaults>
- org.apache.http.*;version="[4.1,5)"
+ org.apache.http.*;version="[4.2,5)"
</camel.osgi.import.before.defaults>
<camel.osgi.export.pkg>org.apache.camel.component.http4.*</camel.osgi.export.pkg>
</properties>
Modified:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java?rev=1381042&r1=1381041&r2=1381042&view=diff
==============================================================================
---
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
(original)
+++
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
Wed Sep 5 07:32:56 2012
@@ -30,7 +30,6 @@ import org.apache.camel.util.jsse.SSLCon
import org.apache.http.auth.params.AuthParamBean;
import org.apache.http.client.params.ClientParamBean;
import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.params.ConnConnectionParamBean;
import org.apache.http.conn.params.ConnRouteParamBean;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
@@ -39,7 +38,7 @@ import org.apache.http.conn.ssl.BrowserC
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.cookie.params.CookieSpecParamBean;
-import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.impl.conn.PoolingClientConnectionManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParamBean;
import org.apache.http.params.HttpParams;
@@ -292,7 +291,7 @@ public class HttpComponent extends Heade
protected ClientConnectionManager createConnectionManager() {
SchemeRegistry schemeRegistry = new SchemeRegistry();
- ThreadSafeClientConnManager answer = new
ThreadSafeClientConnManager(schemeRegistry);
+ PoolingClientConnectionManager answer = new
PoolingClientConnectionManager(schemeRegistry);
if (getMaxTotalConnections() > 0) {
answer.setMaxTotal(getMaxTotalConnections());
}
@@ -312,10 +311,7 @@ public class HttpComponent extends Heade
ClientParamBean clientParamBean = new ClientParamBean(clientParams);
IntrospectionSupport.setProperties(clientParamBean, parameters,
"httpClient.");
-
- ConnConnectionParamBean connConnectionParamBean = new
ConnConnectionParamBean(clientParams);
- IntrospectionSupport.setProperties(connConnectionParamBean,
parameters, "httpClient.");
-
+
ConnRouteParamBean connRouteParamBean = new
ConnRouteParamBean(clientParams);
IntrospectionSupport.setProperties(connRouteParamBean, parameters,
"httpClient.");
Modified:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java?rev=1381042&r1=1381041&r2=1381042&view=diff
==============================================================================
---
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
(original)
+++
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
Wed Sep 5 07:32:56 2012
@@ -52,6 +52,7 @@ import org.apache.http.client.methods.Ht
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.ContentType;
import org.apache.http.entity.FileEntity;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.entity.StringEntity;
@@ -408,9 +409,12 @@ public class HttpProducer extends Defaul
try {
Object data = in.getBody();
if (data != null) {
- String contentType =
ExchangeHelper.getContentType(exchange);
-
- if (contentType != null &&
HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentType)) {
+ String contentTypeString =
ExchangeHelper.getContentType(exchange);
+ ContentType contentType = null;
+ if (contentTypeString != null) {
+ contentType = ContentType.parse(contentTypeString);
+ }
+ if (contentTypeString != null &&
HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentTypeString)) {
// serialized java object
Serializable obj =
in.getMandatoryBody(Serializable.class);
// write object to output stream
@@ -424,7 +428,11 @@ public class HttpProducer extends Defaul
// file based (could potentially also be a FTP file
etc)
File file = in.getBody(File.class);
if (file != null) {
- answer = new FileEntity(file, contentType);
+ if (contentType != null) {
+ answer = new FileEntity(file, contentType);
+ } else {
+ answer = new FileEntity(file);
+ }
}
} else if (data instanceof String) {
// be a bit careful with String as any type can most
likely be converted to String
@@ -433,7 +441,9 @@ public class HttpProducer extends Defaul
// (for example application/x-www-form-urlencoded
forms being sent)
String charset = IOHelper.getCharsetName(exchange,
false);
StringEntity entity = new StringEntity((String) data,
charset);
- entity.setContentType(contentType);
+ if (contentType != null) {
+ entity.setContentType(contentType.toString());
+ }
answer = entity;
}
@@ -442,7 +452,9 @@ public class HttpProducer extends Defaul
// force the body as an input stream since this is the
fallback
InputStream is =
in.getMandatoryBody(InputStream.class);
InputStreamEntity entity = new InputStreamEntity(is,
-1);
- entity.setContentType(contentType);
+ if (contentType != null) {
+ entity.setContentType(contentType.toString());
+ }
answer = entity;
}
}