[
https://issues.apache.org/jira/browse/HTTPCORE-337?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mike Corneille updated HTTPCORE-337:
------------------------------------
Description:
Problem: The 302 redirect doesn't work because the "location" header isn't
properly transposed. By copying all headers from the origin to the client
respolves the 302 problem. There could be other issues with simply transposing
all headers, but this is a good fix to add for now...
Examples found on page:
http://hc.apache.org/httpcomponents-core-ga/examples.html
http://hc.apache.org/httpcomponents-core-ga/httpcore-nio/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
+import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.nio.ContentEncoder;
@@ -46,6 +47,11 @@ class ProxyResponseProducer implements
HttpAsyncResponseProducer
// Rewrite response!!!!
BasicHttpResponse r = new
BasicHttpResponse(response.getStatusLine());
+ Header[] locations = response.getHeaders("location");
+ for (Header header: locations)
+ {
+ r.addHeader(header);
+ }
r.setEntity(response.getEntity());
return r;
}
was:
Problem: The 302 redirect doesn't work because the "location" header isn't
properly transposed. By copying all headers from the origin to the client
respolves the 302 problem. There could be other issues with simply transposing
all headers, but this is a good fix to add for now...
Examples found on page:
http://hc.apache.org/httpcomponents-core-ga/examples.html
http://hc.apache.org/httpcomponents-core-ga/httpcore-nio/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
@@ -46,6 +46,8 @@ class ProxyResponseProducer implements
HttpAsyncResponseProducer
// Rewrite response!!!!
BasicHttpResponse r = new
BasicHttpResponse(response.getStatusLine());
+ r.setHeaders(response.getAllHeaders());
+
r.setEntity(response.getEntity());
return r;
}
> Example Fix: NIO Reverse Proxy Server Example
> ---------------------------------------------
>
> Key: HTTPCORE-337
> URL: https://issues.apache.org/jira/browse/HTTPCORE-337
> Project: HttpComponents HttpCore
> Issue Type: Bug
> Components: Examples
> Affects Versions: 4.2.4
> Reporter: Mike Corneille
> Priority: Minor
>
> Problem: The 302 redirect doesn't work because the "location" header isn't
> properly transposed. By copying all headers from the origin to the client
> respolves the 302 problem. There could be other issues with simply
> transposing all headers, but this is a good fix to add for now...
> Examples found on page:
> http://hc.apache.org/httpcomponents-core-ga/examples.html
> http://hc.apache.org/httpcomponents-core-ga/httpcore-nio/examples/org/apache/http/examples/nio/NHttpReverseProxy.java
> +import org.apache.http.Header;
> import org.apache.http.HttpResponse;
> import org.apache.http.message.BasicHttpResponse;
> import org.apache.http.nio.ContentEncoder;
> @@ -46,6 +47,11 @@ class ProxyResponseProducer implements
> HttpAsyncResponseProducer
> // Rewrite response!!!!
> BasicHttpResponse r = new
> BasicHttpResponse(response.getStatusLine());
>
> + Header[] locations = response.getHeaders("location");
> + for (Header header: locations)
> + {
> + r.addHeader(header);
> + }
> r.setEntity(response.getEntity());
> return r;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]