Package jodd.http

Class HttpTunnel


  • public class HttpTunnel
    extends java.lang.Object
    Simple HTTP tunnel base ready to be extended.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  HttpTunnel.HttpTunnelConnection
      Single connection handler that performs the tunneling.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.concurrent.ExecutorService executorService  
      protected int listenPort
      Tunnel listening port.
      protected boolean running  
      protected java.net.ServerSocket serverSocket  
      protected int socketBacklog
      Number of incoming sockets connection that can be hold before processing each.
      protected java.lang.String targetHost
      Target host.
      protected int targetPort
      Target port.
      protected int threadPoolSize
      The number of threads that can be executed in parallel.
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpTunnel()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Runnable onSocketConnection​(java.net.Socket socket)
      Invoked on incoming connection.
      void start()
      Starts HTTP tunnel.
      void stop()
      Stops the tunnel, shutdowns the thread pool and closes server socket.
      • Methods inherited from class java.lang.Object

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

      • threadPoolSize

        protected int threadPoolSize
        The number of threads that can be executed in parallel.
      • socketBacklog

        protected int socketBacklog
        Number of incoming sockets connection that can be hold before processing each.
      • listenPort

        protected int listenPort
        Tunnel listening port.
      • targetHost

        protected java.lang.String targetHost
        Target host.
      • targetPort

        protected int targetPort
        Target port.
      • executorService

        protected java.util.concurrent.ExecutorService executorService
      • running

        protected volatile boolean running
      • serverSocket

        protected java.net.ServerSocket serverSocket
    • Constructor Detail

      • HttpTunnel

        public HttpTunnel()
    • Method Detail

      • start

        public void start()
                   throws java.io.IOException
        Starts HTTP tunnel. Method ends when the tunnel is stopped.
        Throws:
        java.io.IOException
      • onSocketConnection

        protected java.lang.Runnable onSocketConnection​(java.net.Socket socket)
        Invoked on incoming connection. By default returns HttpTunnel.HttpTunnelConnection to handle the connection. May be used to return custom handlers.
      • stop

        public void stop()
        Stops the tunnel, shutdowns the thread pool and closes server socket.