Package rabbit.proxy

Examples of rabbit.proxy.HttpProxy


     * @param response the actual response being sent.
     */
    public AdFilter (Connection con, HttpHeader request, HttpHeader response) {
  super (con, request, response);
  int idx = -1
  HttpProxy proxy = con.getProxy ();
  adreplacer = proxy.getConfig ().getProperty (getClass ().getName (),
                 "adreplacer",
                 ADREPLACER);
  while ((idx = adreplacer.indexOf ("$proxy")) > -1) {
      adreplacer = adreplacer.substring(0,idx) +
    proxy.getHost ().getHostName () + ":" + proxy.getPort () +
    adreplacer.substring (idx + "$proxy".length ());
  }
    }
View Full Code Here


     */
    private HttpHeader handleURLSetup (String requri, HttpHeader header,
               Connection con) {
  try {
      // is this request to our self?
      HttpProxy proxy = con.getProxy ();
      if (requri != null && requri.charAt (0) == '/') {
    requri =
        "http://" + proxy.getHost ().getHostName () +
        ":" + proxy.getPort () + requri;
    header.setRequestURI (requri);
      }
      URL url = new URL (requri);
      header.setHeader ("Host"
            url.getPort () > -1 ?
            url.getHost () + ":" + url.getPort () :
            url.getHost ());
      int urlport = url.getPort ();
      // This could give a DNS-error if no DNS is available.
      // And since we have not decided if we should proxy it
      // up the chain yet, do string comparison..
      // InetAddress urlhost = InetAddress.getByName (url.getHost ());     
      String uhost = url.getHost ();
      if (proxy.isSelf (uhost, urlport)) {
    con.setMayUseCache (false);
    con.setMayCache (false);
    con.setMayFilter (false);
    if (!userHandler.isValidUser (con.getUserName (),
                con.getPassword ())
View Full Code Here

      } else {
    BigInteger b3 = bi.subtract (ONE);
    header.setHeader ("Max-Forwards", b3.toString ());
      }
  } catch (NumberFormatException e) {
      HttpProxy proxy = con.getProxy ();
      proxy.getLogger ().logWarn ("Bad number for Max-Forwards: '" +
          val + "'");
  }
  return null;
    }
View Full Code Here

  for (int i = 0; i < rsize; i++) {
      String r = removes.get (i);
      header.removeHeader (r);
  }
 
  HttpProxy proxy = con.getProxy ();
  if (proxy.isProxyConnected ()) {
      String auth = proxy.getProxyAuthString ();
      // it should look like this (using RabbIT:RabbIT):
      // Proxy-authorization: Basic UmFiYklUOlJhYmJJVA==
      header.setHeader ("Proxy-authorization",
            "Basic " + Coder.uuencode (auth));
  }
View Full Code Here

  addStatus (sb);
  return PageCompletion.PAGE_DONE;
    }   

    private void addStatus (StringBuilder sb) {
  HttpProxy proxy = con.getProxy ();
  List<Connection> connections = proxy.getCurrentConnections ();
  sb.append ("Version: " + proxy.getVersion () + "<br>\n" );
  sb.append ("Running on: " + proxy.getHost () + " <B>:</B> " +
       proxy.getPort () + "<br>\n" );
  sb.append ("Started at: " + new Date (proxy.getStartTime ()) +
       "<br>\n" );
  sb.append ("Current time: " + new Date () + "<br>\n" );
  sb.append ("Alive and kicking with " + connections.size () +
       " current connections.<br>\n" );
 
  sb.append (HtmlPage.getTableHeader (100, 1));
  sb.append (HtmlPage.getTableTopicRow ());
  sb.append ("<th width=\"20%\">Type</th>" +
       "<th width=\"20%\">Read</th>" +
       "<th width=\"20%\">Write</th>" +
       "<th width=\"20%\">TransferTo</th>" +
       "<th width=\"20%\">TransferFrom</th></tr>\n");
  TrafficLoggerHandler tlh = proxy.getTrafficLoggerHandler ();
  synchronized (tlh) {
      appendTL (sb, "Client", tlh.getClient ());
      appendTL (sb, "Network", tlh.getNetwork ());
      appendTL (sb, "Cache", tlh.getCache ());
      appendTL (sb, "Proxy", tlh.getProxy ());
  }
  sb.append ("</table>\n<br>\n");
 
  sb.append (HtmlPage.getTableHeader (100, 1));
  sb.append (HtmlPage.getTableTopicRow ());
  sb.append ("<th width=\"20%\">InetAddress</th><th>Id</th>" +
       "<th width=\"50%\">Connection</th>" +
       "<th width=\"20%\">Status</th><th>Time(s)</th></tr>\n");

  long now = System.currentTimeMillis ();
  for (Connection hth : connections) {
      sb.append ("<tr><td>");
      InetAddress ia = hth.getChannel ().socket ().getInetAddress ();
      if (ia != null)
    sb.append (ia.getHostAddress ());
      else
    sb.append ("?");
      sb.append ("</td><td><nobr>").append (hth.getId ());
      sb.append ("</nobr></td><td>").append (hth.getRequestLine ());
      sb.append ("</td><td>").append (hth.getStatus ());
      sb.append ("</td><td>").append ((now - hth.getStarted ()) / 1000);
      sb.append ("</td></tr>\n");
  }

  sb.append ("</table>\n<br>\n");
  sb.append (HtmlPage.getTableHeader (100, 1));
  sb.append (HtmlPage.getTableTopicRow ());
  sb.append ("<th>thingy</th><th width=\"10%\">times</th></tr>\n");
  Set<String> e = proxy.getCounter ().keys ();
  List<String> ls = new ArrayList<String> (e);
  Collections.sort (ls);
  for (String type : ls) {
      int val = proxy.getCounter ().get (type);
      sb.append ("\t<tr><td>").append (type);
      sb.append ("</td><td>").append (val).append ("</td></tr>\n");
  }
  sb.append ("</table>\n")
    }
View Full Code Here

  long origSize = size;
  String convert = config.getProperty ("convert", STD_CONVERT);
  String convargs = config.getProperty ("convertargs", STD_CONVERT_ARGS);
 
  int idx = 0;
  HttpProxy proxy = con.getProxy ();
  String entryName =
      proxy.getCache ().getEntryName (entry.getId (), false);
  try {
      while ((idx = convargs.indexOf ("$filename")) > -1) {
    convargs = convargs.substring (0, idx) + entryName +
        convargs.substring (idx + "$filename".length());
      }
View Full Code Here

  addStatus (sb);
  return PageCompletion.PAGE_DONE;
    }   
   
    private void addStatus (StringBuilder sb) {
  HttpProxy proxy = con.getProxy ();
  ConnectionHandler ch = proxy.getConnectionHandler ();
  sb.append ("<br>\n");
  sb.append ("Keepalive is set to: ");
  sb.append (ch.getKeepaliveTime () / 1000);
  sb.append (" s.<br>\n");
   sb.append (HtmlPage.getTableHeader (100, 1));
View Full Code Here

TOP

Related Classes of rabbit.proxy.HttpProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.