net.i2p.i2ptunnel.localServer

## Class LocalHTTPServer

- java.lang.Object
- - net.i2p.i2ptunnel.localServer.LocalHTTPServer

-     public abstract class LocalHTTPServer
      extends Object

  Very simple web server. Serve local files in the docs/ directory, for CSS and images in error pages, using the reserved address proxy.i2p (similar to p.p in privoxy). This solves the problems with including links to the router console, as assuming the router console is at 127.0.0.1 leads to broken links if it isn't.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `LocalHTTPServer()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected static String` | `_t(String key)` lang in routerconsole.lang property, else current locale
    `protected static String` | `_t(String key, Object o)` {0}
    `protected static String` | `_t(String key, Object o, Object o2)` {0} and {1}
    `static String` | `decode(String s)` Decode %xx encoding
    `static void` | `serveLocalFile(I2PAppContext context, I2PSocketManager sockMgr, OutputStream out, String method, String targetRequest, String query, String proxyNonce, boolean allowGzip)` Very simple web server.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LocalHTTPServer

          public LocalHTTPServer()

  - ### Method Detail

    - #### _t

          protected static String _t(String key)

      lang in routerconsole.lang property, else current locale

    - #### _t

          protected static String _t(String key,
                                     Object o)

      {0}

    - #### _t

          protected static String _t(String key,
                                     Object o,
                                     Object o2)

      {0} and {1}

    - #### decode

          public static String decode(String s)

      Decode %xx encoding

    - #### serveLocalFile

          public static void serveLocalFile(I2PAppContext context,
                                            I2PSocketManager sockMgr,
                                            OutputStream out,
                                            String method,
                                            String targetRequest,
                                            String query,
                                            String proxyNonce,
                                            boolean allowGzip)
                                     throws IOException

      Very simple web server. Serve local files in the docs/ directory, for CSS and images in error pages, using the reserved address proxy.i2p (similar to p.p in privoxy). This solves the problems with including links to the router console, as assuming the router console is at 127.0.0.1 leads to broken links if it isn't. Ignore all request headers (If-Modified-Since, etc.) There is basic protection here - FileUtil.readFile() prevents traversal above the base directory - but inproxy/gateway ops would be wise to block proxy.i2p to prevent exposing the docs/ directory or perhaps other issues through uncaught vulnerabilities. Restrict to the /themes/ directory for now.
      Parameters:
        `sockMgr` - only for /b32, otherwise ignored
        `targetRequest` - decoded path only, non-null
        `query` - raw (encoded), may be null
      Throws:
        `IOException`