Package org.w3c.jigsaw.http

Examples of org.w3c.jigsaw.http.HTTPException


    protected void error(Request request, String msg)
  throws ProtocolException
    {
  Reply reply = request.makeReply(HTTP.INTERNAL_SERVER_ERROR);
  reply.setContent(msg);
  throw new HTTPException(reply);
    }
View Full Code Here


  Client client = request.getClient();
  if ( client != null ) {
      try {
    client.sendContinue();
      } catch (IOException ex) {
    throw new HTTPException(ex.getMessage());
      }
  }
  // Now, only, get the data:
  try {
      if (request.hasTransferEncoding("gzip"))
View Full Code Here

  LookupState   ls = null;
  try {
      ls = new LookupState(request);
  } catch (org.w3c.tools.resources.ProtocolException ex) {
      ex.printStackTrace();
      throw new HTTPException(ex);
  }
  LookupResult  lr = new LookupResult(null);
  ResourceReference rr = null; // cr
  ls.markInternal();
  if ( ! ls.hasMoreComponents() )
View Full Code Here

  error.setContent("Method GET not implemented.<br><br>"+
       "The administration server does not use plain "+
       "HTTP but a variant of it. The only tool available "+
       "for now is an application called <b>JigAdmin</b>. "+
       "Please read the documentation.");
  throw new HTTPException (error) ;
    }
View Full Code Here

  try {
      writer.writeResource(root, bout);
  } catch (IOException ex) {
      System.out.println(ex.getMessage());
      ex.printStackTrace();
      throw new HTTPException("unable to dump root");
  } catch (Exception ex) {
      System.out.println(ex.getMessage());
      ex.printStackTrace();
      throw new HTTPException("unable to dump root: "+ex.getMessage());
  }
  byte bits[] = bout.toByteArray();
  // Setup the reply:
  Reply reply = request.makeReply(HTTP.OK);
  reply.setStream(new ByteArrayInputStream(bits));
View Full Code Here

  } else {
      // Ok, that's targeted toward a specific target resource:
      try {
    reply = (Reply)broker.perform(request);
      } catch (org.w3c.tools.resources.ProtocolException ex) {
    throw new HTTPException(ex);
      }
  }
  //outgoing filters
  for (int i = filters.length-1 ; i > -1 ; i--) {
      Reply rep = (Reply) filters[i].outgoingFilter(req, reply);
View Full Code Here

      error.setContent("<html><head><title>Server Error</title>"+
           "</head><body><h1>Server misconfigured</h1>"+
           "<p>The resource <b>"+getIdentifier()+"</b>"+
           "has an invalid target attribute : <p><b>"+
           getTarget()+"</b></body></html>");     
      throw new HTTPException (error);
  }
  return server.perform(request);
    }
View Full Code Here

        String msg = "Simultaneous number of access to this page "
      + "is limited to " + limit + " you was not able to "
      + "get in." ;
        Reply error = request.makeReply(HTTP.SERVICE_UNAVAILABLE);
        error.setContent (msg) ;
        throw new HTTPException (error) ;
    }
      } else {
    try {
        wait() ;
    } catch (InterruptedException ex) {
View Full Code Here

          svalue + "].");
        getServer().errlog(this, msg);
        // Throw an HTTPException:
        reply = request.makeReply(HTTP.INTERNAL_SERVER_ERROR);
        reply.setContent("CGI script emited invalid status.");
        throw new HTTPException(reply);
    }
    // we will use the default for this frame, but remove
    // the length calculated from the script size.
    reply = createDefaultReply(request, status);
    reply.setContentLength(-1);
      } else {
    // No status code available, any location header ?
    if (location != null) {
        reply = request.makeReply(HTTP.FOUND);
    } else {
        reply = createDefaultReply(request, HTTP.OK);
        reply.setContentLength(-1);
    }
      }
      // Set up the location header if needed:
      if ( location != null ) {
    try {
        reply.setLocation(new URL(getURL(request), location));
    } catch (MalformedURLException ex) {
        // This should really not happen:
        getServer().errlog(this, "unable to create location url "+
               location+
               " in base "+getURL(request));
    }
      }
      // And then, the remaining headers:
      Enumeration e = h.enumerateHeaders();
      if ( e != null ) {
    while ( e.hasMoreElements() ) {
        String hname = (String) e.nextElement();
        reply.setValue(hname, (String) h.getValue(hname));
    }
      }
      reply.setStream(p.getInputStream()) ;
  } catch (IOException ex) {
      ex.printStackTrace();
  } catch (MimeParserException ex) {
      // This script has generated invalid output:
      String msg = (getURL(request)
        +": emited invalid output ["+
        ex.getMessage() +"]");
      getServer().errlog(this, msg);
      // Throw an HTTPException:
      Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
      error.setContent("CGI error: unable to parse script headers.") ;
      throw new HTTPException (error) ;
  }
  if (reply != null) {
      reply.setDynamic(true);
  }
  return reply ;
View Full Code Here

  String      command[] = getCommand() ;
  if ( command == null ) {
      Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
      error.setContent("CgiResource mis-configured: it doesn't have a "
           + " command attribute");
      throw new HTTPException(error);
  }
  // Ok:
  Vector      env       = new Vector(32) ;
  httpd       server    = request.getClient().getServer() ;
  InetAddress sadr      = server.getInetAddress() ;
View Full Code Here

TOP

Related Classes of org.w3c.jigsaw.http.HTTPException

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.