Package rabbit.http

Examples of rabbit.http.HttpHeader


    /** Get a 412 Precondition Failed header.
     * @return a suitable HttpHeader.
     */
    public HttpHeader get412 () {
  HttpHeader header = getHeader ("HTTP/1.1 412 Precondition Failed");
  String sh = "412 Precondition Failed";
  StringBuilder accreq =
      new StringBuilder (HtmlPage.getPageHeader (con, sh) +
             "</body></html>\n");
  header.setContent (accreq.toString ());
  return header;
    }
View Full Code Here


    /** Get a 414 Request-URI Too Long
     * @return a suitable HttpHeader.
     */
    public HttpHeader get414 () {
  HttpHeader header = getHeader ("HTTP/1.1 414 Request-URI Too Long");
  String sh = "414 Request-URI Too Long";
  StringBuilder accreq =
      new StringBuilder (HtmlPage.getPageHeader (con, sh) +
             "</body></html>\n");
  header.setContent (accreq.toString ());
  return header;
    }
View Full Code Here

     * @param exception the Exception made.
     * @return a suitable HttpHeader.
     */
    public HttpHeader get416 (Throwable exception) {
  String sh = "HTTP/1.1 416 Requested Range Not Satisfiable ";
  HttpHeader header = getHeader (sh);
  String shh = "416 Requested Range Not Satisfiable";
  StringBuilder accreq =
      new StringBuilder (HtmlPage.getPageHeader (con, shh) +
             "Request out of range: " + exception +
             ".</b>\n</body></html>\n");
  header.setContent (accreq.toString ());
  return header;
    }
View Full Code Here

    /** Get a 417 Expectation Failed header.
     * @param expectation the expectation that failed.
     * @return a suitable HttpHeader.
     */
    public HttpHeader get417 (String expectation) {
  HttpHeader header = getHeader ("HTTP/1.1 417 Expectation failed");
  String sh = "417 Expectation failed";
  StringBuilder accreq =
      new StringBuilder (HtmlPage.getPageHeader (con, sh) +
             "RabbIT does not handle the '" + expectation +
             "' kind of expectations yet.</b>\n" +
             "</body></html>\n");
  header.setContent (accreq.toString ());
  return header;
    }
View Full Code Here

     * @return a suitable HttpHeader.
     */
    public HttpHeader get500 (Throwable exception) {
  // in most cases we should have a header out already, but to be sure...
  // normally this only thrashes the page... Too bad.
  HttpHeader header = getHeader ("HTTP/1.1 500 Internal Server Error ")
  StringWriter sw = new StringWriter ();
  PrintWriter sos = new PrintWriter (sw);
  exception.printStackTrace (sos);
 
  Properties sysprop = System.getProperties ();
 
  HttpProxy proxy = con.getProxy ();
  Config config = proxy.getConfig ();
  String sh = "500 Internal Server Error";
  StringBuilder sb =
      new StringBuilder (HtmlPage.getPageHeader (con, sh));
  sb.append ("You have found a bug in RabbIT please report this" +
       "(together with the URL you tried to visit) to the " +
       "<a href=\"http://www.khelekore.org/rabbit/\" target =" +
       "\"_top\">RabbIT</a> crew.<br><br>\n" +
       "<font size = 4>Connection status</font><br><hr noshade>\n" +
       "status: " + con.getStatus ()  + "<br>\n" +
       "started: " + new Date (con.getStarted ()) + "<br>\n" +
       "keepalive: " + con.getKeepalive () + "<br>\n" +
       "meta: " + con.getMeta () + "<br>\n" +
       "mayusecache: " + con.getMayUseCache () + "<br>\n" +
       "maycache: " + con.getMayCache () + "<br>\n" +
       "mayfilter: " + con.getMayFilter () + "<br>\n"+
       "requestline: " + con.getRequestLine () + "<br>\n" +
       "statuscode: " + con.getStatusCode () + "<br>\n" +
       "extrainfo: " + con.getExtraInfo () + "<br>\n" +           
       "contentlength: " + con.getContentLength () + "<br>\n" +
       "<br>\n" +
       "<font size = 4>Proxy status</font><br>\n<hr noshade>\n" +
       "proxy version: " + proxy.VERSION + "<br>\n" +
       "proxy identity: " + proxy.getServerIdentity () + "<br>\n" +
       "server host: " + proxy.getHost () + "<br>\n" +
       "server port: " + proxy.getPort () + "<br>\n" +
       "accessfilters: " +
       config.getProperty ("Filters", "accessfilters") +
       "<br>\n" +
       "httpinfilters: " +
       config.getProperty ("Filters", "httpinfilters") +
       "<br>\n" +
       "httpoutfilters:" +
       config.getProperty ("Filters", "httpoutfilters") +
       "<br>\n<br>\n" +                 
       "<font size = 4>System properties</font><br>\n" +
       "<hr noshade>\n" +
       "java.version: " +
       sysprop.getProperty ("java.version") + "<br>\n" +
       "java.vendor: " +
       sysprop.getProperty ("java.vendor") + "<br>\n" +
       "os.name: " +
       sysprop.getProperty ("os.name") + "<br>\n" +
       "os.version: " +
       sysprop.getProperty ("os.version") + "<br>\n" +
       "os.arch: " +
       sysprop.getProperty ("os.arch") + "<br>\n" +
       "error is:<BR><XMP>\n" + sw +
       "</XMP><br>" +
       "<hr noshade>\n" +
       "</body></html>\n");
  header.setContent (sb.toString ());
  return header;
    }
View Full Code Here

    /** Get a 504 Gateway Timeout for the given exception.
     * @param exception the Exception made.
     * @return a suitable HttpHeader.
     */
    public HttpHeader get504 (Throwable exception, String requestLine) {
  HttpHeader header = getHeader ("HTTP/1.1 504 Gateway Time-out ");
 
  HttpHeader hh = new HttpHeader ();
  hh.setRequestLine (requestLine);
  String uri = hh.getRequestURI ();
  try {
      URL u = new URL (uri);
      StringBuilder content =
    new StringBuilder ("\n\n<br>Did you mean to go to: <ul>");
      Set<String> places = new HashSet<String> ();
View Full Code Here

  if (rh.entry == null)
      return false;
  String method = request.getMethod ();
  if (!method.equals ("GET"))
      return false;
  HttpHeader resp = rh.dataHook;
  String realLength = resp.getHeader ("RabbIT-Partial");
  return (realLength != null);
    }
View Full Code Here

      return;
  String range = request.getHeader ("Range");
  if (range == null)
      return;
  Date d = HttpDateParser.getDate (ifRange);
  HttpHeader oldresp = rh.dataHook;
  if (d == null) {
      // we have an etag...
      String etag = oldresp.getHeader ("Etag");
      if (etag == null || !checkWeakEtag (etag, ifRange))
    setMayUseCache (false);
  }
    }
View Full Code Here

     * @param status the status code of the error.
     * @param message the error message to tell the client.
     */
    public void doError (int status, String message) {
  this.statusCode = Integer.toString (status);
  HttpHeader header = responseHandler.getHeader ("HTTP/1.0 400 Bad Request");
  StringBuilder error =
      new StringBuilder (HtmlPage.getPageHeader (this, "400 Bad Request") +
             "Unable to handle request:<br><b>" +
             message +
             "</b></body></html>\n");
  header.setContent (error.toString ());
  sendAndClose (header);
    }
View Full Code Here

  String message = sw.toString ();
  this.statusCode = Integer.toString (statuscode);
  extraInfo = (extraInfo != null ?
         extraInfo + e.toString () :
         e.toString ());
  HttpHeader header = null;
  if (statuscode == 504)
      header = getHttpGenerator ().get504 (e, requestLine);
  else
      header = getHttpGenerator ().getHeader ("HTTP/1.0 400 Bad Request");
 
  StringBuilder sb = new StringBuilder ();
  sb.append (HtmlPage.getPageHeader (this, statuscode + " " +
             header.getReasonPhrase ()) +
       "Unable to handle request:<br><b>" +
       e.getMessage () +
       (header.getContent () != null ?
        "<br>" + header.getContent () :
        "") +
       "</b><br><xmp>" + message + "</xmp></body></html>\n");
  header.setContent (sb.toString ());
  sendAndClose (header);
    }
View Full Code Here

TOP

Related Classes of rabbit.http.HttpHeader

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.