Author: davsclaus
Date: Wed Nov 26 03:14:08 2008
New Revision: 720809
URL: http://svn.apache.org/viewvc?rev=720809&view=rev
Log:
Merged revisions 720806 via svnmerge from
https://svn.apache.org/repos/asf/activemq/camel/trunk
........
r720806 | davsclaus | 2008-11-26 12:07:50 +0100 (on, 26 nov 2008) | 1 line
CAMEL-1109: Applied patch with thanks and added a test for it in camel-jetty
........
Modified:
activemq/camel/branches/camel-1.x/ (props changed)
activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpOperationFailedException.java
activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 26 03:14:08 2008
@@ -1 +1 @@
-/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719864,719978-719979,720207,720435-720437
+/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719864,719978-719979,720207,720435-720437,720806
Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpOperationFailedException.java
URL:
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpOperationFailedException.java?rev=720809&r1=720808&r2=720809&view=diff
==============================================================================
---
activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpOperationFailedException.java
(original)
+++
activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpOperationFailedException.java
Wed Nov 26 03:14:08 2008
@@ -20,24 +20,27 @@
import org.apache.camel.CamelException;
import org.apache.camel.util.ObjectHelper;
+import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.StatusLine;
public class HttpOperationFailedException extends CamelException {
private final String redirectLocation;
private final int statusCode;
private final StatusLine statusLine;
+ private final Header[] headers;
private final InputStream responseBody;
- public HttpOperationFailedException(int statusCode, StatusLine statusLine,
String location, InputStream responseBody) {
+ public HttpOperationFailedException(int statusCode, StatusLine statusLine,
String location, Header[] headers, InputStream responseBody) {
super("HTTP operation failed with statusCode: " + statusCode + ",
status: " + statusLine + (location != null ? ", redirectLocation: " + location
: ""));
this.statusCode = statusCode;
this.statusLine = statusLine;
this.redirectLocation = location;
+ this.headers = headers;
this.responseBody = responseBody;
}
- public HttpOperationFailedException(int statusCode, StatusLine statusLine,
InputStream responseBody) {
- this(statusCode, statusLine, null, responseBody);
+ public HttpOperationFailedException(int statusCode, StatusLine statusLine,
Header[] headers, InputStream responseBody) {
+ this(statusCode, statusLine, null, headers, responseBody);
}
public boolean isRedirectError() {
@@ -60,9 +63,12 @@
return statusCode;
}
+ public Header[] getHeaders() {
+ return headers;
+ }
+
public InputStream getResponseBody() {
return responseBody;
}
-
}
\ No newline at end of file
Modified:
activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
URL:
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java?rev=720809&r1=720808&r2=720809&view=diff
==============================================================================
---
activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
(original)
+++
activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
Wed Nov 26 03:14:08 2008
@@ -104,20 +104,21 @@
}
} else {
HttpOperationFailedException exception = null;
+ Header[] headers = method.getResponseHeaders();
InputStream is = extractResponseBody(method);
if (responseCode >= 300 && responseCode < 400) {
String redirectLocation;
Header locationHeader =
method.getResponseHeader("location");
if (locationHeader != null) {
redirectLocation = locationHeader.getValue();
- exception = new
HttpOperationFailedException(responseCode, method.getStatusLine(),
redirectLocation, is);
+ exception = new
HttpOperationFailedException(responseCode, method.getStatusLine(),
redirectLocation, headers, is);
} else {
// no redirect location
- exception = new
HttpOperationFailedException(responseCode, method.getStatusLine(), is);
+ exception = new
HttpOperationFailedException(responseCode, method.getStatusLine(), headers, is);
}
} else {
// internal server error (error code 500)
- exception = new HttpOperationFailedException(responseCode,
method.getStatusLine(), is);
+ exception = new HttpOperationFailedException(responseCode,
method.getStatusLine(), headers, is);
}
if (exception != null) {
Modified:
activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java?rev=720809&r1=720808&r2=720809&view=diff
==============================================================================
---
activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
(original)
+++
activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyResponseBodyWhenErrorTest.java
Wed Nov 26 03:14:08 2008
@@ -38,6 +38,8 @@
String body = context.getTypeConverter().convertTo(String.class,
cause.getResponseBody());
assertTrue(body.indexOf("Damm") > -1);
assertTrue(body.indexOf("IllegalArgumentException") > -1);
+ assertNotNull(cause.getHeaders());
+ assertTrue("Should have http header with content type set",
cause.getHeaders()[0].getValue().indexOf("text/plain") > -1);
}
}