jira-importer opened a new issue, #961:
URL: https://github.com/apache/httpcomponents-core/issues/961

   **[Mike 
Corneille](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=horshaque)**
 opened 
**[HTTPCORE-337](https://issues.apache.org/jira/browse/HTTPCORE-337?redirect=false)**
 and commented
   
   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[] headers = response.getAllHeaders();
   
   + 
   
         for (Header header: headers)
   
   + 
   
         {
   
   + 
   
         if (!header.getName().toLowerCase().equals("transfer-encoding") && 
!header.getName().toLowerCase().equals("content-length")
   
   + 
   
         && !header.getName().toLowerCase().equals("connection"))
   
   + 
   
         {
   
   + 
   
         r.addHeader(header);
   
   + 
   
         }
   
   + 
   
             }
             r.setEntity(response.getEntity());
             return r;
         }
   
   @@ -118,4 +137,4 @@ class ProxyRequestProducer implements 
HttpAsyncRequestProducer
   +
   
       if (!header.getName().toLowerCase().equals("host") && 
!header.getName().toLowerCase().equals("content-length"))
   
   + 
   
         {
   
   + 
   
         r.addHeader(header);
   
   + 
   
         }
   
   + 
   
         }
   
   + 
   
             r.setEntity(((HttpEntityEnclosingRequest) request).getEntity());
             return r;
         }
         else
         {
   
   - 
   
         return new BasicHttpRequest(request.getRequestLine());
   
   + 
   
         BasicHttpRequest r = new BasicHttpRequest(request.getRequestLine());
   
   + 
   
         Header[] headers = request.getAllHeaders();
   
   + 
   
         for (Header header: headers)
   
   + 
   
         {
   
   + 
   
         if (!header.getName().toLowerCase().equals("host") && 
!header.getName().toLowerCase().equals("content-length"))
   
   + 
   
         {
   
   + 
   
         r.addHeader(header);
   
   + 
   
         }
   
   + 
   
         }
   
   + 
   
   + 
   
                 return r;
             }
         }
   
   
   
   ---
   
   **Affects:** 4.2.4
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to