All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pastdev.httpcomponents.servlet.ReverseProxyResponseUtil Maven / Gradle / Ivy

There is a newer version: 0.1.3
Show newest version
package com.pastdev.httpcomponents.servlet;


import java.io.IOException;
import java.io.OutputStream;


import javax.servlet.http.HttpServletResponse;


import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;


public class ReverseProxyResponseUtil {
    public static void copyResponseEntity( HttpResponse proxyResponse,
            HttpServletResponse servletResponse ) throws IOException {
        HttpEntity entity = proxyResponse.getEntity();
        if ( entity != null ) {
            OutputStream servletOutputStream = servletResponse.getOutputStream();
            entity.writeTo( servletOutputStream );
        }
    }

    public static void copyResponseHeaders( HttpResponse proxyResponse,
            HttpServletResponse servletResponse ) {
        for ( Header header : proxyResponse.getAllHeaders() ) {
            if ( ReverseProxyServlet.HOB_BY_HOP_HEADERS.containsHeader(
                    header.getName() ) )
                continue;
            servletResponse.addHeader( header.getName(), header.getValue() );
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy