You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2008/03/20 15:53:32 UTC
svn commit: r639302 -
/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
Author: ningjiang
Date: Thu Mar 20 07:53:31 2008
New Revision: 639302
URL: http://svn.apache.org/viewvc?rev=639302&view=rev
Log:
CAMEL-374 Path applied with thanks to David
Modified:
activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
Modified: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java?rev=639302&r1=639301&r2=639302&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java (original)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java Thu Mar 20 07:53:31 2008
@@ -33,21 +33,27 @@
*/
public class HttpBinding {
- // This should be a set of lower-case strings
+ // This should be a set of lower-case strings
public static final Set<String> DEFAULT_HEADERS_TO_IGNORE = new HashSet<String>(Arrays.asList(
"content-length", "content-type", HttpProducer.HTTP_RESPONSE_CODE.toLowerCase()));
private Set<String> ignoredHeaders = DEFAULT_HEADERS_TO_IGNORE;
/**
* Writes the exchange to the servlet response
- *
+ *
* @param response
* @throws IOException
*/
public void writeResponse(HttpExchange exchange, HttpServletResponse response) throws IOException {
Message out = exchange.getOut();
if (out != null) {
-
+
+ // Set the status code in the response. Default is 200.
+ if (out.getHeader(HttpProducer.HTTP_RESPONSE_CODE) != null) {
+ int responseCode = ((Integer)out.getHeader(HttpProducer.HTTP_RESPONSE_CODE)).intValue();
+ response.setStatus(responseCode);
+ }
+
// Write out the headers...
for (String key : out.getHeaders().keySet()) {
String value = out.getHeader(key, String.class);
@@ -55,7 +61,7 @@
response.setHeader(key, value);
}
}
-
+
// Write out the body.
if (out.getBody() != null) {
@@ -86,7 +92,7 @@
HttpServletRequest request = httpMessage.getRequest();
return request.getReader();
}
-
+
/*
* Exclude a set of headers from responses and new requests as all headers get
* propagated between exchanges by default
@@ -111,7 +117,7 @@
public void setIgnoredHeaders(Set<String> headersToIgnore) {
ignoredHeaders = headersToIgnore;
}
-
+
public Set<String> getIgnoredHeaders() {
return ignoredHeaders;
}