Package rabbit.http

Examples of rabbit.http.HttpHeader


    private void checkAndHandleSSL (ByteBuffer buffer) {
  SSLHandler sslh = new SSLHandler (proxy, this, request, tlh);
  if (sslh.isAllowed ()) {
      sslh.handle (channel, selector, buffer);
  } else {
      HttpHeader badresponse = responseHandler.get403 ();
      sendAndClose (badresponse);
  }
    }      
View Full Code Here


      closeDown ();
 
    }

    private void sendOkReplyAndTunnel (ByteBuffer server2client) {
  HttpHeader reply = new HttpHeader ();
  reply.setStatusLine ("HTTP/1.0 200 Connection established");
  reply.setHeader ("Proxy-agent", proxy.getServerIdentity ());
 
  HttpHeaderSentListener tc = new TunnelConnected (server2client);
  try {
      HttpHeaderSender sender =
    new HttpHeaderSender (channel, selector, proxy.getLogger (),
View Full Code Here

    private boolean checkVary (Connection con, HttpHeader req,
             Connection.RequestHandler rh) {
  CacheEntry<HttpHeader, HttpHeader> entry = rh.entry;
  if (entry == null)
      return false;
  HttpHeader resp = rh.dataHook;
  List<String> varies = resp.getHeaders ("Vary");
  for (String vary : varies) {
      if (vary.equals ("*")) {
    con.setMayUseCache (false);
    return false;
      } else {
    HttpHeader origreq = entry.getKey ();
    List<String> vals = origreq.getHeaders (vary);
    List<String> nvals = req.getHeaders (vary);
    if (vals.size () != nvals.size ()) {
        return setupRevalidation (con, req, rh);
    } else {
        for (String val : vals) {
View Full Code Here

  if (entry == null)
      return false;
  boolean noCache = false;
  // Only check the response header,
  // request headers with no-cache == refetch.
  HttpHeader resp = rh.dataHook;
  noCache = checkNoCacheHeader (resp.getHeaders ("Cache-Control"));
  if (noCache) {
      return setupRevalidation (con, header, rh);
  }
  return false;
    }
View Full Code Here

               Connection.RequestHandler rh) {
  CacheEntry<HttpHeader, HttpHeader> entry = rh.entry;
  if (entry == null)
      return false;
 
  HttpHeader resp = rh.dataHook;
  for (String ncc : resp.getHeaders ("Cache-Control")) {
      String[] sts = ncc.split (",");
      for (String nc : sts) {
    nc = nc.trim ();
    if (nc.equals ("must-revalidate") ||
        nc.equals ("proxy-revalidate")) {
View Full Code Here

  CacheEntry<HttpHeader, HttpHeader> entry = rh.entry;
  con.setMayUseCache (false);
  String method = req.getMethod ();
  // if we can not filter (noproxy-request) we can not revalidate...
  if (method.equals ("GET") && entry != null && con.getMayFilter ()) {
      HttpHeader resp = rh.dataHook;
      String etag = resp.getHeader ("ETag");
      String lmod = resp.getHeader ("Last-Modified");
      if (etag != null) {
    String inm = req.getHeader ("If-None-Match");
    if (inm == null) {
        req.setHeader ("If-None-Match", etag);
        con.setAddedINM (true);
View Full Code Here

    boolean checkMaxStale (HttpHeader req, Connection.RequestHandler rh) {
  for (String cc : req.getHeaders ("Cache-Control")) {
      cc = cc.trim ();
      if (cc.equals ("max-stale")) {
    if (rh.entry != null) {
        HttpHeader resp = rh.dataHook;
        long maxAge =
      rh.cond.getCacheControlValue (resp, "max-age=");
        if (maxAge >= 0) {
      long now = System.currentTimeMillis ();
      long secs = (now - rh.entry.getCacheTime ()) / 1000;
      long currentAge = secs;
      String age = resp.getHeader ("Age");
      if (age != null)
          currentAge += Long.parseLong (age);
      if (currentAge > maxAge) {
          resp.addHeader ("Warning",
              "110 RabbIT \"Response is stale\"");
      }
        }
    }
    return true;
View Full Code Here

        Connection.RequestHandler rh) {
  if (rh.entry == null)
      return;
  if (rh.webHeader.getStatusCode ().trim ().equals ("304"))
      return;
  HttpHeader cachedWebHeader = rh.dataHook;

  String sd = rh.webHeader.getHeader ("Date");
  String cd = cachedWebHeader.getHeader ("Date");
  if (sd != null && cd != null) {
      Date d1 = HttpDateParser.getDate (sd);
      Date d2 = HttpDateParser.getDate (cd);
      // if we get a response with a date older than we have,
      // we keep our cache.
View Full Code Here

    private void updateRange (CacheEntry<HttpHeader, HttpHeader> old,
            HttpHeader response,
            PartialCacher pc,
            Cache<HttpHeader, HttpHeader> cache) { 
  HttpHeader oldRequest = old.getKey ();
  HttpHeader oldResponse = old.getDataHook (cache);
  String cr = oldResponse.getHeader ("Content-Range");
  if (cr == null) {
      String cl = oldResponse.getHeader ("Content-Length");
      if (cl != null) {
    long size = Long.parseLong (cl);
    cr = "bytes 0-" + (size - 1) + "/" + size;
      }
  }
  ContentRangeParser crp = new ContentRangeParser (cr, getLogger ());
  if (crp.isValid ()) {
      long start = crp.getStart ();
      long end = crp.getEnd ();
      long total = crp.getTotal ();
      String t = total < 0 ? "*" : Long.toString (total);
      if (end == pc.getStart () - 1) {
    oldRequest.setHeader ("Range",
              "bytes=" + start + "-" + end);
    oldResponse.setHeader ("Content-Range",
               "bytes " + start + "-" +
               pc.getEnd () + "/" + t);
      } else {
    oldRequest.addHeader ("Range",
              "bytes=" + start + "-" + end);
    oldResponse.addHeader ("Content-Range",
               "bytes " + start + "-" +
               pc.getEnd () + "/" + t);
      }
      cache.entryChanged (old, oldRequest, oldResponse);
  }
View Full Code Here

      do404 (filename.substring (7));
      return;
  }

  // TODO: check etag/if-modified-since and handle it.
  HttpHeader response = con.getHttpGenerator ().getHeader ();
  setMime (filename, response);

  length = fle.length ();
  response.setHeader ("Content-Length", Long.toString (length));
  con.setContentLength (response.getHeader ("Content-Length"));
  Date lm = new Date (fle.lastModified () -
          con.getProxy ().getOffset ());
  response.setHeader ("Last-Modified",
          HttpDateParser.getDateString (lm))
  try {
      fis = new FileInputStream (filename);
  } catch (IOException e) {
      throw (new IllegalArgumentException ("Could not open file: '" +
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.