Class DefaultApache31ProxyEngine

  • All Implemented Interfaces:
    ProxyEngine

    public class DefaultApache31ProxyEngine
    extends java.lang.Object
    implements ProxyEngine
    ProxyEngine implementation for Orbeon. Used Apache HttpClient 3.1.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String extractNamespace​(javax.servlet.http.HttpServletRequest request)
      Extracts the namespace coming from client.
      protected ConfigurationService getConfigurationService()  
      protected java.lang.String getHostPart​(java.lang.String url)
      Gets the host part of an URL, including protocol, host, port with no trailing slash.
      protected org.apache.http.client.HttpClient getHttpClient()  
      protected java.lang.String getPrefixFromRequest​(javax.servlet.http.HttpServletRequest request)
      Gets the prefix from the request URI address.
      protected boolean isTextFile​(java.lang.String contentType)
      Returns true if the given contentType refers to a text file.
      void proxy​(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String namespace, java.lang.String url, boolean forceGetMethod, java.util.Map<java.lang.String,​java.lang.String> headers)
      Proxies content
      protected void sendRequestHeaders​(java.util.Set<java.lang.String> headers, javax.servlet.http.HttpServletRequest request, org.apache.http.client.methods.HttpRequestBase httpMethod)
      Sends headers from the request to the remote server.
      protected void sendResponseHeaders​(java.util.Set<java.lang.String> headers, org.apache.http.Header[] responseHeaders, javax.servlet.http.HttpServletResponse response)
      Get headers from remote connection and copies them back to the current response.
      void setConfigurationService​(ConfigurationService configurationService)  
      void setHeadersFrom​(java.util.List<java.lang.String> headersFrom)  
      void setHeadersTo​(java.util.List<java.lang.String> headersTo)  
      void setHttpClient​(org.apache.http.client.HttpClient httpClient)  
      void setUrlRewriter​(UrlRewriter urlRewriter)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_CHARSET

        protected static final java.lang.String DEFAULT_CHARSET
      • ORBEON_PREFIX_PLUS_SLASH

        protected static final java.lang.String ORBEON_PREFIX_PLUS_SLASH
        See Also:
        Constant Field Values
      • LOCATION_HEADER

        protected static final java.lang.String LOCATION_HEADER
        See Also:
        Constant Field Values
      • CONTENT_TYPE_HEADER

        protected static final java.lang.String CONTENT_TYPE_HEADER
        See Also:
        Constant Field Values
      • headersTo

        protected final java.util.Set<java.lang.String> headersTo
      • headersFrom

        protected final java.util.Set<java.lang.String> headersFrom
    • Constructor Detail

      • DefaultApache31ProxyEngine

        public DefaultApache31ProxyEngine()
    • Method Detail

      • extractNamespace

        public java.lang.String extractNamespace​(javax.servlet.http.HttpServletRequest request)
        Extracts the namespace coming from client.
        Specified by:
        extractNamespace in interface ProxyEngine
        Parameters:
        request -
      • proxy

        public void proxy​(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response,
                          java.lang.String namespace,
                          java.lang.String url,
                          boolean forceGetMethod,
                          java.util.Map<java.lang.String,​java.lang.String> headers)
                   throws ProxyException
        Description copied from interface: ProxyEngine
        Proxies content
        Specified by:
        proxy in interface ProxyEngine
        Parameters:
        request - The HttpServletRequest associated to the call
        response - The HttpServletResponse associated to the call
        namespace - Used for HTML element's id generation
        url - The url to be called
        forceGetMethod - Useful when proxying content, when false it uses the same method used in the original request.
        headers - Extra headers to be passed to the connection, useful for authentication headers.
        Throws:
        ProxyException
      • getHostPart

        protected java.lang.String getHostPart​(java.lang.String url)
        Gets the host part of an URL, including protocol, host, port with no trailing slash.
        Parameters:
        url -
      • getPrefixFromRequest

        protected java.lang.String getPrefixFromRequest​(javax.servlet.http.HttpServletRequest request)
        Gets the prefix from the request URI address.
        Parameters:
        request -
      • isTextFile

        protected boolean isTextFile​(java.lang.String contentType)
        Returns true if the given contentType refers to a text file.
        Parameters:
        contentType -
      • sendRequestHeaders

        protected void sendRequestHeaders​(java.util.Set<java.lang.String> headers,
                                          javax.servlet.http.HttpServletRequest request,
                                          org.apache.http.client.methods.HttpRequestBase httpMethod)
        Sends headers from the request to the remote server.
        Parameters:
        headers - headers that should be sent
        request - Request to take header values from.
        httpMethod - httpMethod
      • sendResponseHeaders

        protected void sendResponseHeaders​(java.util.Set<java.lang.String> headers,
                                           org.apache.http.Header[] responseHeaders,
                                           javax.servlet.http.HttpServletResponse response)
        Get headers from remote connection and copies them back to the current response.
        Parameters:
        headers - headers that should be copied back
        responseHeaders - Remote response Headers
        response - Response to copy header values to.
      • setUrlRewriter

        public void setUrlRewriter​(UrlRewriter urlRewriter)
      • setHeadersTo

        public void setHeadersTo​(java.util.List<java.lang.String> headersTo)
      • setHeadersFrom

        public void setHeadersFrom​(java.util.List<java.lang.String> headersFrom)
      • getHttpClient

        protected org.apache.http.client.HttpClient getHttpClient()
      • setHttpClient

        public void setHttpClient​(org.apache.http.client.HttpClient httpClient)
      • setConfigurationService

        public void setConfigurationService​(ConfigurationService configurationService)