Class HTTPProxy


  • public class HTTPProxy
    extends java.lang.Object
    Simple server-side HTTP Request / Response
    Author:
    davidc
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.servlet.http.HttpServletResponse response  
      protected java.net.URL url  
    • Constructor Summary

      Constructors 
      Constructor Description
      HTTPProxy​(java.lang.String requestUrl, javax.servlet.http.HttpServletResponse response)
      Construct
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void initialiseResponse​(java.net.URLConnection urlConnection)
      Initialise response
      void service()
      Perform request
      protected void setRequestHeaders​(java.net.URLConnection urlConnection)
      Set request headers
      protected void writeResponse​(java.io.InputStream input, java.io.OutputStream output)
      Write response
      • Methods inherited from class java.lang.Object

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

      • url

        protected java.net.URL url
      • response

        protected javax.servlet.http.HttpServletResponse response
    • Constructor Detail

      • HTTPProxy

        public HTTPProxy​(java.lang.String requestUrl,
                         javax.servlet.http.HttpServletResponse response)
                  throws java.net.MalformedURLException
        Construct
        Parameters:
        requestUrl - url to request
        response - response to write request back to
        Throws:
        java.net.MalformedURLException
    • Method Detail

      • service

        public void service()
                     throws java.io.IOException
        Perform request
        Throws:
        java.io.IOException
      • initialiseResponse

        protected void initialiseResponse​(java.net.URLConnection urlConnection)
        Initialise response
        Parameters:
        urlConnection - url connection
      • setRequestHeaders

        protected void setRequestHeaders​(java.net.URLConnection urlConnection)
        Set request headers
        Parameters:
        urlConnection - url connection
      • writeResponse

        protected void writeResponse​(java.io.InputStream input,
                                     java.io.OutputStream output)
                              throws java.io.IOException
        Write response
        Parameters:
        input - input stream of request
        output - output stream of response
        Throws:
        java.io.IOException