Class I2PTunnelHTTPClientBase

    • Method Detail

      • getPrefix

        protected String getPrefix​(long requestId)
      • selectProxy

        protected String selectProxy​(String host)
        Simple random selection, with caching by hostname, and avoidance of the last one to fail.
        Parameters:
        host - the clearnet hostname we're targeting
        Returns:
        null if none configured
      • selectSSLProxy

        protected String selectSSLProxy​(String host)
        Only for SSL via HTTPClient. ConnectClient should use selectProxy() Unlike selectProxy(), we parse the option on the fly so it can be changed. selectProxy() requires restart...
        Returns:
        null if none configured
        Since:
        0.9.11, moved from I2PTunnelHTTPClient in 0.9.39
      • noteProxyResult

        protected void noteProxyResult​(String proxy,
                                       String host,
                                       boolean isSSL,
                                       boolean ok)
        Update the cache and note if failed.
        Parameters:
        proxy - which
        host - clearnet hostname targeted
        isSSL - set to FALSE for ConnectClient
        ok - success or failure
        Since:
        0.9.39
      • getRealm

        protected abstract String getRealm()
      • isDigestAuthRequired

        protected boolean isDigestAuthRequired()
        Since:
        0.9.4
      • authorize

        protected I2PTunnelHTTPClientBase.AuthResult authorize​(Socket s,
                                                               long requestId,
                                                               String method,
                                                               String authorization)
        Authorization Ref: RFC 2617 If the socket is an InternalSocket, no auth required.
        Parameters:
        method - GET, POST, etc.
        authorization - may be null, the full auth line e.g. "Basic lskjlksjf"
        Returns:
        success
      • getAuthError

        protected String getAuthError​(boolean isStale)
        What to send if digest auth fails
        Since:
        0.9.4
      • getErrorPage

        protected String getErrorPage​(String base,
                                      String backup)
        foo => errordir/foo-header_xx.ht for lang xx, or errordir/foo-header.ht, or the backup byte array on fail. .ht files must be UTF-8 encoded and use \r\n terminators so the HTTP headers are conformant. We can't use FileUtil.readFile() because it strips \r
        Returns:
        non-null
        Since:
        0.9.4 moved from I2PTunnelHTTPClient
      • getErrorPage

        protected static String getErrorPage​(I2PAppContext ctx,
                                             String base,
                                             String backup)
        foo => errordir/foo-header_xx.ht for lang xx, or errordir/foo-header.ht, or the backup byte array on fail. .ht files must be UTF-8 encoded and use \r\n terminators so the HTTP headers are conformant. We can't use FileUtil.readFile() because it strips \r
        Returns:
        non-null
        Since:
        0.9.4 moved from I2PTunnelHTTPClient
      • handleClientException

        protected void handleClientException​(Exception ex,
                                             OutputStream out,
                                             String targetRequest,
                                             boolean usingWWWProxy,
                                             String wwwProxy,
                                             long requestId)
        Parameters:
        ex - may be null
        Since:
        0.9.14 moved from subclasses
      • handleI2PSocketException

        protected void handleI2PSocketException​(I2PSocketException ise,
                                                OutputStream out,
                                                String targetRequest,
                                                boolean usingWWWProxy,
                                                String wwwProxy)
        Generate an error page based on the status code in our custom exception.
        Parameters:
        ise - may be null
        Since:
        0.9.14
      • writeErrorMessage

        protected void writeErrorMessage​(String errMessage,
                                         OutputStream out,
                                         String targetRequest,
                                         boolean usingWWWProxy,
                                         String wwwProxy,
                                         String jumpServers)
                                  throws IOException
        No extra message
        Parameters:
        jumpServers - comma- or space-separated list, or null
        Throws:
        IOException
        Since:
        0.9.14 moved from subclasses
      • writeErrorMessage

        protected void writeErrorMessage​(String errMessage,
                                         String extraMessage,
                                         OutputStream out,
                                         String targetRequest,
                                         boolean usingWWWProxy,
                                         String wwwProxy)
                                  throws IOException
        No jump servers
        Parameters:
        extraMessage - extra message or null, will be HTML-escaped
        Throws:
        IOException
        Since:
        0.9.14
      • writeErrorMessage

        protected void writeErrorMessage​(String errMessage,
                                         String extraMessage,
                                         OutputStream outs,
                                         String targetRequest,
                                         boolean usingWWWProxy,
                                         String wwwProxy,
                                         String jumpServers)
                                  throws IOException
        Parameters:
        jumpServers - comma- or space-separated list, or null
        extraMessage - extra message or null, will be HTML-escaped
        Throws:
        IOException
        Since:
        0.9.14
      • decodeIDNHost

        public static String decodeIDNHost​(String host)
        Decode a hostname for display. Returns original string on any error.
        Since:
        0.9.50
      • writeFooter

        public static void writeFooter​(OutputStream out)
                                throws IOException
        Flushes. Public only for LocalHTTPServer, not for general use
        Throws:
        IOException
        Since:
        0.9.14 moved from I2PTunnelHTTPClient
      • writeFooter

        public static void writeFooter​(Writer out)
                                throws IOException
        Flushes. Public only for LocalHTTPServer, not for general use
        Throws:
        IOException
        Since:
        0.9.19
      • _t

        protected String _t​(String key)
        Translate
        Since:
        0.9.14 moved from I2PTunnelHTTPClient
      • _t

        protected String _t​(String key,
                            Object o)
        Translate {0}
        Since:
        0.9.14 moved from I2PTunnelHTTPClient
      • _t

        protected String _t​(String key,
                            Object o,
                            Object o2)
        Translate {0} and {1}
        Since:
        0.9.14 moved from I2PTunnelHTTPClient