Package org.w3c.jigsaw.http

Examples of org.w3c.jigsaw.http.Request


     * @param request The request being processed.
     * @return Always <strong>null</strong>.
     */

    public synchronized ReplyInterface ingoingFilter(RequestInterface req) {
  Request request = (Request) req;
  int i = getInt (ATTR_COUNTER, 0) + 1;
  setInt(ATTR_COUNTER, i) ;
  if(! request.hasState(STATE_COUNT))
      request.setState(STATE_COUNT, new Integer(i)) ;
  return null;
    }
View Full Code Here


     * @param request The request being processed.
     * @return <strong>null</strong> if ok a "Use Proxy" otherwise.
     */

    public synchronized ReplyInterface ingoingFilter(RequestInterface req) {
  Request request = (Request) req;
  Client cl = request.getClient();
  if (cl instanceof org.w3c.jigsaw.http.socket.SocketClient) {
      SocketClient sc = (SocketClient) cl;
      InetAddress ia = sc.getInetAddress();
      if (ia.equals(proxy_ia)) // same, it is ok :)
    return null;
  }
  // failed, restrict access
  Reply r = request.makeReply(HTTP.USE_PROXY);
  if (r != null) {
      HtmlGenerator g = new HtmlGenerator("Use Proxy");
      g.append("You should use the following proxy to access" +
         " this resource: " + getString(ATTR_PROXY, "localhost"));
      r.setStream(g);
View Full Code Here

    public ReplyInterface ingoingFilter(RequestInterface req,
          FilterInterface[] filters,
          int fidx)
  throws ProtocolException
    {
  Request request = (Request) req;
  String method = request.getMethod() ;
 
  if(! method.equals("GET") )
      return null ;
 
  tag(request) ;
 
  if(isCachable(request)) {
      SimpleCacheEntry ent = cache.retrieve(request) ;
      if(ent != null) {
    Reply fRep = null ;
    fRep = applyIn(request,filters,fidx) ;
    if(fRep != null) return fRep ;
   
    Reply reply = request.makeReply(HTTP.NOHEADER) ;
   
    fRep = applyOutSkip(request,reply,filters,fidx) ;
    if(fRep != null) return fRep ;
   
    try {
        ent.dump(request.getClient().getOutputStream()) ;
    } catch(IOException ex) {
        return null ;
    }
    return reply ;
      }
View Full Code Here

           ReplyInterface rep,
           FilterInterface[] filters,
           int fidx)
  throws ProtocolException
    {
  Request request = (Request) req;
  Reply   reply   = (Reply) rep;
  if(!isTagged(request))
      return null ;
 
  if(isCachable(reply)) {
View Full Code Here

  } catch (ProtocolException ex) {
      throw ex;
  } catch (ResourceException ex) {
      throw ex;
  } catch (Exception ex) {
      Request request = (Request) req;
      Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR);
      PageCompileOutputStream err = new PageCompileOutputStream();
      PrintWriter writer = new PrintWriter(err);
      writer.print("The generated frame at\n\n"+
       request.getURL()+"\n\n"+
       "reported this exception : \n\n"+ex.getMessage()+
       "\n\nStack trace : \n\n");
      ex.printStackTrace(writer);
      writer.flush();
      writer.close();
View Full Code Here

    public ReplyInterface outgoingFilter (RequestInterface req,
            ReplyInterface rep)
  throws ProtocolException
    {
  Request request = (Request) req;
  Reply   reply   = (Reply) rep;
  Process       process   = null ;
  ProcessFeeder feeder    = null ;
  String        command[] = getCommand() ;

  // Some sanity checks:
  if (reply.getStatus() != HTTP.OK)
      return null;
  InputStream in = reply.openStream() ;
  if ( in == null )
      return null;
  if ( command == null ) {
      Reply error = request.makeReply(HTTP.INTERNAL_SERVER_ERROR) ;
      error.setContent("The process filter of this resource is not "
           + " configured properly (it has no command).");
      throw new HTTPException(error);
  }
  // Okay, run the reply stream through the process:
  try {
      process = runtime.exec (command) ;
  } catch (IOException e) {
      Reply error = request.makeReply(HTTP.NOT_FOUND) ;
      error.setContent("The filter's process command "+
           command[0]+
           " wasn't found: "+e.getMessage()) ;
      throw new HTTPException (error);
  }
View Full Code Here

     * @param req the current request to be handled
     * @exception ProtocolException thrown if the request url is malformed
     */
    public void perform(RequestInterface req)
  throws ProtocolException  {
  Request request = (Request)req;
  if (ssl_enabled) {
      // set request protocol to https
      URL url = request.getURL();
      try {
    request.setURL(new URL("https", url.getHost(),
               url.getPort(), url.getFile()));
   
    // tk, 1 February 2004, added SSL client attributes
    // according to Servlet v2.4 spec
    SSLSession session = getSession(request);
    if (null != session) {
        String algorithm = session.getCipherSuite();
        request.setState(ALGORITHM, algorithm);
       
        Integer keysize = getKeySize(algorithm, session);
        if (null != keysize) {
      request.setState(KEYSIZE, keysize);
        }
       
        try {
                        Certificate[] chain = getPeerCertificates(session);
                        if (chain instanceof X509Certificate[]) {
                            X509Certificate[] x509chain;
          x509chain = (X509Certificate[])chain;
                            request.setState(CERTCHAIN, x509chain);
                            request.setState(AuthFilter.STATE_AUTHTYPE,
               CLIENT_CERT_AUTH);
                            if (x509chain.length > 0) {
        request.setState(AuthFilter.STATE_AUTHUSER,
                x509chain[0].getSubjectDN().getName());
                            }
                        }
        } catch (SSLPeerUnverifiedException ex) {
      if (debug) {
View Full Code Here

    public ReplyInterface ingoingFilter(RequestInterface req,
          FilterInterface[] filters,
          int fidx)
  throws ProtocolException
    {
  Request request = (Request) req;
  if(cache == null)
      cache = new Cache(getMaxSize(),
            getMaxEntries(),
            getDefaultMaxAge()) ;

  String method = request.getMethod() ;
  if(! ( method.equals("HEAD") ||
         method.equals("GET") ) )
      return null // Enforce write-through

  tag(request) ;
View Full Code Here

           ReplyInterface rep,
           FilterInterface[] filters,
           int fidx)
  throws ProtocolException
    {
  Request request = (Request) req;
  Reply   reply   = (Reply) rep;
  // Be transparent if request is not "ours"
  if(!isTagged(request))
      return null ;
 
View Full Code Here

     * because an abnormal situation occured.
     */
    public ReplyInterface ingoingFilter(RequestInterface request)
  throws ProtocolException
    {
  Request req = (Request) request;
  Reply   rep = null;
  if (checkHeaders(req)) {
      return null;
  }
  rep = req.makeReply(HTTP.FORBIDDEN);
  HtmlGenerator g = new HtmlGenerator("Forbidden - Headers missing");
  g.append("Some Headers, mandatory for this resource, are missing.");
  if (sendHeaderList && (headerNames != null)) {
      g.append("<ul>");
      for (int i=0; i<headerNames.length; i++) {
View Full Code Here

TOP

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

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.