Package jodd.http

Class HttpTunnel.HttpTunnelConnection

  • All Implemented Interfaces:
    java.lang.Runnable
    Enclosing class:
    HttpTunnel

    public class HttpTunnel.HttpTunnelConnection
    extends java.lang.Object
    implements java.lang.Runnable
    Single connection handler that performs the tunneling.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.net.Socket socket  
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpTunnelConnection​(java.net.Socket socket)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void onRequest​(HttpRequest request)
      Invoked after income connection is parsed.
      protected void onResponse​(HttpResponse response)
      Invoked after target response is processed.
      void run()  
      protected void tunnel()
      Performs the tunneling.
      • Methods inherited from class java.lang.Object

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

      • socket

        protected final java.net.Socket socket
    • Constructor Detail

      • HttpTunnelConnection

        public HttpTunnelConnection​(java.net.Socket socket)
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • onRequest

        protected void onRequest​(HttpRequest request)
        Invoked after income connection is parsed. Nothing is changed in the request, except the target host and port.
      • onResponse

        protected void onResponse​(HttpResponse response)
        Invoked after target response is processed. Response is now ready to be sent back to the client. The following header parameters are changed:
        • Transfer-Encoding is removed, as body is returned at once,
        • Content-Length is added/update to body size.
      • tunnel

        protected void tunnel()
                       throws java.io.IOException
        Performs the tunneling. The following steps occurs:
        • read and parse clients request
        • open socket to target
        • resend request to target
        • read targets response
        • fix response and resend it to client
        Throws:
        java.io.IOException