Package org.w3c.jigsaw.http

Examples of org.w3c.jigsaw.http.Reply


    protected static Reply error(CvsFrame cvsframe,
         Request request,
         String msg,
         String details)
    {
  Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR);
  HtmlGenerator g = getHtmlGenerator(cvsframe, msg);
  g.append ("<center>");
  g.append ("[ <A HREF=\"./CVS\">Back</A> ]<hr noshade width=\"80%\">");
  g.append ("</center>");
  g.append ("<div class=\"error\"> <center><p class=\"error\">", msg,
      "</center><p>\n");
  g.append ("Details : <p><em>",details,"</em><p></div>\n");
  g.append ("<hr noshade width=\"80%\">");
  error.setStream(g);
  return error;
    }
View Full Code Here


      } else if ( status == CVS.DIR_NCO ) {
    // Checkout directory, and relocate:
    getCvsManager().updateDirectory(name);
    Request request = (Request)ls.getRequest();
    if ( request != null ) {
        Reply relocate = request.makeReply(HTTP.FOUND);
        try {
      URL myloc    = getURL(request);
      URL location = new URL(myloc, name+"/CVS");
      relocate.setLocation(location);
      lr.setReply(relocate);
        } catch (Exception ex) {
        }
    }
    lr.setTarget(null);
View Full Code Here

  throws ProtocolException
    {
  try {
      getCvsManager().refresh();
  } catch (CvsException ex) {
      Reply error =
    error(this, request, "Error while refreshing directory", ex);
      throw new HTTPException (error) ;
  }
    }
View Full Code Here

      g.append("<center><hr noshade width=\"80%\">",head,"</center>");
  }

  g.close() ;
  // Send back the reply:
  Reply reply = request.makeReply(HTTP.OK) ;
  reply.setHeaderValue(reply.H_CACHE_CONTROL, CACHE_CONTROL_NOCACHE);
  reply.setHeaderValue(reply.H_PRAGMA, PRAGMA_NOCACHE);
  reply.setStream(g);
  return reply ;
    }
View Full Code Here

  InputStream in    = new StringBufferInputStream(query) ;
  URLDecoder  d     = new URLDecoder (in, getOverrideFlag()) ;
  try {
      d.parse () ;
  } catch (URLDecoderException e) {
      Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
      error.setContent("Invalid request:unable to decode form data.");
      throw new HTTPException (error) ;
  } catch (IOException e) {
      Reply error = request.makeReply(HTTP.BAD_REQUEST) ;
      error.setContent("Invalid request: unable to read form data.");
      throw new HTTPException (error) ;
  }

  String action = d.getValue("action") ;
  return (action == null ? "unknown" : action);
View Full Code Here

  String action  = data.getValue("action") ;
  String scope   = data.getValue("scope");

  // no action, is a bug in the generated form (see get)
  if ( action == null ) {
      Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
      error.setContent("No action selected !");
      throw new HTTPException (error) ;
  }

  // Check action's scope:
  Enumeration gen_enum = null;
View Full Code Here

  if (asisreply == null) {
      // not parsed, try to serve it as a normal file
      return super.createDefaultReply(request, status);
  }
  // create the reply with the parsed status
  Reply reply = super.createDefaultReply(request, asisreply.getStatus());
  reply.setReason(asisreply.getReason());
  // and update all defined headers
  Enumeration e = asisreply.enumerateHeaderDescriptions();
  while ( e.hasMoreElements() ) {
      HeaderDescription d = (HeaderDescription) e.nextElement();
      HeaderValue       v = asisreply.getHeaderValue(d);
      if ( v != null )
    reply.setHeaderValue(d, v);
  }
  return reply;
    }
View Full Code Here

     */
    protected Reply createFileReply(Request request)
  throws ProtocolException, ResourceException
    {
  File file = fresource.getFile() ;
  Reply reply = null;
  // Won't check for range request, as we don't control the status
  // Default to full reply then
  reply = createDefaultReply(request, HTTP.OK) ;
  try {
      FileInputStream fis = new FileInputStream(file);
      // and escape the headers
      fis.skip(foffset);
      reply.setStream(fis);
  } catch (IOException ex) {
      Reply error = request.makeReply(HTTP.SERVICE_UNAVAILABLE);
      error.setContent(ex.getMessage());
      return error;
  }
  return reply ;
    }
View Full Code Here

     * got a fatal error.
     */
    protected Reply createFileReply(Request request)
  throws ProtocolException, ResourceException
    {
  Reply reply = null;
  if (zipfresource == null) {
      throw new ResourceException("this frame is not attached to a "+
          "ZipFileResource. ("+
          resource.getIdentifier()+")");
  }
  // Default to full reply:
  reply = createDefaultReply(request, HTTP.OK) ;
  InputStream in = zipfresource.getInputStream();
  if (in != null)
      reply.setStream(in);
  return reply ;
    }
View Full Code Here

    {
  if (fresource == null)
      throw new ResourceException("this frame is not attached to a "+
          "FileResource. ("+
          resource.getIdentifier()+")");
  Reply reply = null;
  File file = fresource.getFile() ;
  fresource.checkContent();
  updateCachedHeaders();
  // Check validators:
  int cim = checkIfMatch(request);
  if ((cim == COND_FAILED) || (cim == COND_WEAK)) {
      reply = request.makeReply(HTTP.PRECONDITION_FAILED);
      reply.setContent("Pre-conditions failed.");
      reply.setContentMD5(null);
      return reply;
  }
  if ( checkIfUnmodifiedSince(request) == COND_FAILED ) {
      reply = request.makeReply(HTTP.PRECONDITION_FAILED);
      reply.setContent("Pre-conditions failed.");
      reply.setContentMD5(null);
      return reply;
  }
  if ( checkValidators(request) == COND_FAILED) {
      return createDefaultReply(request, HTTP.NOT_MODIFIED);
 
  // Does this file really exists, if so send it back
  if ( zipfresource.hasEntry()) {
      reply = createFileReply(request);
      if (request.hasState(STATE_CONTENT_LOCATION))
    reply.setContentLocation(getURL(request).toExternalForm());
      return reply;
  } else {
      return deleteMe(request);
  }
    }
View Full Code Here

TOP

Related Classes of org.w3c.jigsaw.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.