Package org.w3c.www.protocol.http

Examples of org.w3c.www.protocol.http.Reply


      Request req = http.createRequest();
      req.setMethod("LOAD-ROOT");
      req.setURL(server);
      req.setValue("TE","gzip");
      // Run that request:
      Reply rep = runRequest(req);
      // Decode the reply:
      root = reader.readResource(server, null, getInputStream(rep));
  } catch (RemoteAccessException ex) {
      if (debug)
    ex.printStackTrace();
View Full Code Here


        req.setMethod("REINDEX-RESOURCE");
    } else {
        req.setMethod("REINDEX-LOCALLY");
    }
    // Run it:
    Reply rep = admin.runRequest(req);
      } catch (RemoteAccessException rae) {
    throw rae;
      } catch (Exception ex) {
    ex.printStackTrace();
    throw new RemoteAccessException(ex.getMessage());
View Full Code Here

  try {
      Request req = createRequest();
      // Prepare the request:
      req.setMethod("DELETE-RESOURCE");
      // Run it:
      Reply rep = admin.runRequest(req);
  } catch (RemoteAccessException rae) {
      throw rae;
  } catch (Exception ex) {
      ex.printStackTrace();
      throw new RemoteAccessException(ex.getMessage());
View Full Code Here

    req.addTransferEncoding("gzip");
      }
      req.setOutputStream(new ByteArrayInputStream(bits));
 
      // Run that request:
      Reply rep = admin.runRequest(req);
  } catch (RemoteAccessException rae) {
      throw rae;
  } catch (Exception ex) {
      ex.printStackTrace();
      throw new RemoteAccessException("exception "+ex.getMessage());
View Full Code Here

      Request req = createRequest();
      req.setMethod("LOAD-RESOURCE");
      req.setURL(new URL(url.toString()+
             URLEncoder.encode(identifier)));
      // Run it:
      Reply rep = admin.runRequest(req);
      // Decode the reply:
      InputStream in = getInputStream(rep);
      RemoteResource  ret =
    admin.reader.readResource(url,identifier,in);
      in.close();
View Full Code Here

      if (!debug) {
    req.addTransferEncoding("gzip");
      }
      req.setOutputStream(new ByteArrayInputStream(bits));
      // Run it:
      Reply rep = admin.runRequest(req);

      // Decode the result:
      rd = admin.reader.readResourceDescription(getInputStream(rep));
      RemoteResource ret =
    new PlainRemoteResource(admin, url, rd.getIdentifier(), rd);
View Full Code Here

    req.addTransferEncoding("gzip");
      }
      req.setOutputStream(new ByteArrayInputStream(bits));

      // Run it:
      Reply rep = admin.runRequest(req)
  } catch (RemoteAccessException rae) {
      throw rae;
  } catch (Exception ex) {
      ex.printStackTrace();
      throw new RemoteAccessException(ex.getMessage());
View Full Code Here

    req.addTransferEncoding("gzip");
      }
      req.setOutputStream(new ByteArrayInputStream(bits));

      // Run it:
      Reply rep = admin.runRequest(req);
      dframe =
    admin.reader.readResourceDescription(getInputStream(rep));
      id = dframe.getIdentifier();
      URL url = null;
      if (isFrame()) {
View Full Code Here

  try {
      Request req = createRequest();
      // Prepare the request:
      req.setMethod("LOAD-RESOURCE");
      // Run it:
      Reply rep = admin.runRequest(req);
      InputStream in = getInputStream(rep);
      this.description =
    admin.reader.readResourceDescription(in);
      createRemoteFrames();
  } catch (RemoteAccessException rae) {
View Full Code Here

    }
    request.setState(STATE_NOCACHE, Boolean.TRUE);
    return null;
      } else {
    // disconnected, abort now!
    Reply reply = request.makeReply(HTTP.GATEWAY_TIMEOUT);
    reply.setContent("The cache cannot be use for "
         + "<p><code>"+request.getMethod()+"</code> "
         + "<strong>"+request.getURL()+"</strong>"
         + ". <p>It is disconnected.");
    return reply;
      }
  }
  // let's try to get the resource!
  URL _ru = request.getURL();
  String requrl = URLUtils.normalize(_ru).toExternalForm();
  // in the pre-cache, wait for full download
  // FIXME should be better than this behaviour...
  // see EntityCachedResource perform's FIXME ;)
  if (precache.containsKey(requrl)) {
      if (debug)
    System.out.println("*** Already downloading: "+ requrl);
      try {
    CachedResource cr = (CachedResource)precache.get(requrl);
    return cr.perform(request);
      } catch (Exception ex) {
    // there was a problem with the previous request,
    // it may be better to do it by ourself
      }
  }
 
  CachedResource res = null;
  try {
      res = store.getCachedResourceReference(requrl);
  } catch (InvalidCacheException ex) {
      res = null;
  }
  // are we disconnected?
  if (request.checkOnlyIfCached() || !connected ) {
      // and no entries...
      EntityCachedResource ecr = null;
      if (res != null) {
    ecr = (EntityCachedResource) res.lookupResource(request);
      }
      if ((res == null) || (ecr == null)) {
    if ( debug )
        trace(request, "unavailable (disconnected).");
    Reply reply = request.makeReply(HTTP.GATEWAY_TIMEOUT);
    reply.setContent("The cache doesn't have an entry for "
         + "<p><strong>"+request.getURL()+"</strong>"
         + ". <p>And it is disconnected.");
    return reply;
      }
      // yeah!
      if (debug) {
    trace(request, (connected) ? " hit - only if cached" :
          " hit while disconneced" );
      }
      if (!validator.isValid(ecr, request)) {
    addWarning(request, WARN_STALE);
      }
      addWarning(request, WARN_DISCONNECTED);
      Reply reply = ecr.perform(request);
    // Add any warnings collected during processing to the reply:
      setWarnings(request, reply);
//FIXME      request.setState(STATE_HOW, HOW_HIT);
      return reply;
  }
  // in connected mode, we should now take care of revalidation and such
  if (res != null) {
      // if not fully loaded, ask for a revalidation FIXME
      if ((res.getLoadState() == CachedResource.STATE_LOAD_PARTIAL) ||
    (res.getLoadState() == CachedResource.STATE_LOAD_ERROR)) {
    setRequestRevalidation(res, request);
    return null;
      }
      if ( validator.isValid(res, request) ) {
    try {
        store.updateResourceGeneration(res);
    } catch (InvalidCacheException ex) {
        // should be ok so...
    }
//FIXME      request.setState(STATE_HOW, HOW_HIT);
    Reply rep = res.perform(request);
    return rep;
      } else {
    if (debug) {
        System.out.println("*** Revalidation asked for " + requrl);
    }
View Full Code Here

TOP

Related Classes of org.w3c.www.protocol.http.Reply

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.