Package com.caucho.server.http

Examples of com.caucho.server.http.CauchoResponse


  {
    while (response instanceof HttpServletResponseWrapper)
      response = (HttpServletResponse) ((HttpServletResponseWrapper) response).getResponse();

    if (response instanceof CauchoResponse) {
      CauchoResponse res = (CauchoResponse) response;

      String currentValue = res.getHeader(header);

      if (currentValue != null) {
        if (currentValue.equals(value)
            || (currentValue.contains(value + ","))
            || (currentValue.contains(", " + value))) {
        }
        else {
          res.setHeader(header, currentValue + ", " + value);
        }
      }
      else {
        res.setHeader(header, value);
      }
    }
    else {
      response.addHeader(header, value);
    }
View Full Code Here


    throws ServletException, IOException
  {
    // This filter is always called before user filters so we know that
    // the request and response are AbstractRequest and Response.
    CauchoRequest req = (CauchoRequest) request;
    CauchoResponse res = (CauchoResponse) response;

    AbstractConstraint []constraints = null;
    if (_methodMap != null)
      constraints = _methodMap.get(req.getMethod());

    if (constraints == null)
      constraints = _constraints;

    AuthorizationResult result = AuthorizationResult.NONE;

    // XXX: better logging on failure

    boolean isPrivateCache = false;
    if (constraints != null) {
      for (AbstractConstraint constraint : constraints) {
        result = constraint.isAuthorized(req, res, _webApp);

        if (constraint.isPrivateCache())
          isPrivateCache = true;

        if (! result.isFallthrough())
          break;
      }
    }

    if (isPrivateCache)
      res.setPrivateCache(true);

    // server/1af3, server/12d2
    if (req.isLoginRequested() && req.login(result.isFail())) {
      if (result.isResponseSent())
        return;
    }

    if (result.isFail()) {
      if (! result.isResponseSent()
          && ! res.isCommitted()
          && res.getStatus() / 100 == 2) {
        res.sendError(HttpServletResponse.SC_FORBIDDEN);
      }

      return;
    }
View Full Code Here

    }

    res.setContentLength((int) cache.getLength());

    if (res instanceof CauchoResponse) {
      CauchoResponse cRes = (CauchoResponse) res;

      cRes.getResponseStream().sendFile(cache.getPath(), cache.getLength());
    }
    else {
      OutputStream os = res.getOutputStream();
      cache.getPath().writeToStream(os);
    }
View Full Code Here

        if (disp == null)
          throw new JspException(L.l("URL `{0}' does not map to any servlet",
                                     url));

        CauchoResponse response = (CauchoResponse) pageContext.getResponse();

        String charEncoding = getCharEncoding();

        if (charEncoding != null)
          response.getResponseStream().setEncoding(charEncoding);

        final ServletRequest request = pageContext.getRequest();

        disp.include(request, response);

        final Integer statusCode
          = (Integer) request.getAttribute("com.caucho.dispatch.response.statusCode");

        //jsp/1jif
        if (statusCode != null) {
          final int status = statusCode.intValue();

          if (status < 200 || status > 299) {
            String message = L.l(
              "c:import status code {0} received while serving {1}",
              statusCode,
              context + url);

            throw new JspException(message);
          }
        }

        /*
        int status = response.getStatus();

        if (status < 200 || status > 299) {
          String message = L.l(
            "c:import status code {0} received while serving {1}",
            status,
            context + url);

          throw new JspException(message);
        }
        */
      }
      else
        handleExternalBody(context + url);
     
      return;
    }

    int colon = url.indexOf(':');
    int slash = url.indexOf('/');
    if (slash == 0 || colon < 0 || slash < 0 || slash < colon) {
      ServletRequest request = pageContext.getRequest();
      CauchoResponse response = (CauchoResponse) pageContext.getResponse();

      String charEncoding = getCharEncoding();

      if (charEncoding != null)
        response.getResponseStream().setEncoding(charEncoding);

      RequestDispatcher disp = request.getRequestDispatcher(url);

      JstlImportResponseWrapper wrapper = new JstlImportResponseWrapper(response);
      disp.include(request, wrapper);

      //jsp/1jie
      int status = wrapper.getStatus();

      if (status < 200 || status > 299) {
        String message = L.l(
          "c:import status code {0} recieved while serving {1}",
          status,
          url);

        throw new JspException(message);
      } else {
        response.setStatus(status);
      }

    }
    else
      handleExternalBody(url);
View Full Code Here

   */
  public void service(ServletRequest request, ServletResponse response)
    throws IOException, ServletException
  {
    CauchoRequest req = (CauchoRequest) request;
    CauchoResponse res = (CauchoResponse) response;

    if (_urlPrefix == null) {
      synchronized (this) {
        if (_urlPrefix == null)
          serverInit(req);
      }
    }

    if (! req.getMethod().equals("POST")) {
      if (log.isLoggable(Level.FINE))
        log.log(Level.FINE, this + " unexpected method " + req.getMethod());
     
      String protocol = _protocolContainer.getName();
      res.setStatus(500, protocol + " Protocol Error");
      PrintWriter out = res.getWriter();
      out.println(protocol + " expects a POST containing an RPC call.");
      return;
    }

    try {
      String pathInfo = req.getPathInfo();
      String queryString = req.getQueryString();
     
      CharBuffer cb = new CharBuffer();
      cb.append(pathInfo);
      cb.append('?');
      cb.append(queryString);
     
      InputStream is = req.getInputStream();

      if (_isDebug) {
      }

      Skeleton skeleton  = (Skeleton) _beanMap.get(cb);

      if (skeleton == null) {
        // If this was a load just to force the initialization, then return
        if (req.getParameter("ejb-load") != null)
          return;
     
        if (_exception != null)
          throw _exception;

        try {
          if (pathInfo == null)
            pathInfo = "";

          skeleton = _protocolContainer.getSkeleton(pathInfo, queryString);
        } catch (Exception e) {
          log.log(Level.WARNING, e.toString(), e);

          skeleton = _protocolContainer.getExceptionSkeleton();

          if (skeleton != null) {
            skeleton._service(req.getInputStream(), res.getOutputStream(), e);

            return;
          }
          else
            throw e;
        }

        if (skeleton == null)
          throw new ServletException(L.l("Can't load skeleton for '{0}?{1}'",
                                         pathInfo, queryString));

        if (skeleton != null) {
          skeleton.setDebug(_isDebug);
          _beanMap.put(cb, skeleton);
        }
      }

      skeleton._service(req.getInputStream(), res.getOutputStream());
    } catch (ServletException e) {
      e.printStackTrace();
      throw e;
    } catch (Throwable e) {
      e.printStackTrace();
View Full Code Here

          if (disp == null)
            throw new JspException(L.l("URL `{0}' does not map to any servlet",
                                       url));

          CauchoResponse response = (CauchoResponse) pageContext.getResponse();
          response.getResponseStream().setEncoding(null);

          disp.include(pageContext.getRequest(), response);
        } catch (FileNotFoundException e) {
          throw new JspException(L.l("`{0}' is an unknown file or servlet.",
                                     url));
        }
      }
      else
        handleExternalBody(context + url);
     
      return;
    }

    int colon = url.indexOf(':');
    int slash = url.indexOf('/');
    if (slash == 0 || colon < 0 || slash < 0 || slash < colon) {
      ServletRequest request = pageContext.getRequest();

      try {
        RequestDispatcher disp = request.getRequestDispatcher(url);

        if (disp == null)
          throw new JspException(L.l("URL `{0}' does not map to any servlet",
                                     url));

        CauchoResponse response = (CauchoResponse) pageContext.getResponse();
        response.getResponseStream().setEncoding(null);

        disp.include(pageContext.getRequest(), response);
      } catch (FileNotFoundException e) {
        throw new JspException(L.l("URL `{0}' is an unknown file or servlet.",
                                   url));
View Full Code Here

    // this is not in a finally block so we can return a real error message
    // if it's not handled.
    // server/1328, server/125i
    if (res instanceof CauchoResponse) {
      CauchoResponse cRes = (CauchoResponse) res;
     
      cRes.close();
    }
    else {
        try {
          OutputStream os = res.getOutputStream();
          if (os != null)
View Full Code Here

    ServletResponse next = _response.getResponse();
    if (next == null)
      throw new NullPointerException();
   
    if (next instanceof CauchoResponse) {
      CauchoResponse cNext = (CauchoResponse) next;

      if (cNext.isCauchoResponseStream())
        _stream = cNext.getResponseStream();
    }

    _isCommitted = false;
    _headerKeys.clear();
    _headerValues.clear();
View Full Code Here

  public void forward(ServletRequest topRequest, ServletResponse topResponse,
                      String method, Invocation invocation,
                      DispatcherType type)
    throws ServletException, IOException
  {
    CauchoResponse cauchoRes = null;

    boolean allowForward = false;
   
    if (_webApp != null)
      allowForward = _webApp.isAllowForwardAfterFlush();

    if (topResponse instanceof CauchoResponse) {
      cauchoRes = (CauchoResponse) topResponse;

      cauchoRes.setForwardEnclosed(! allowForward);
    }

    // jsp/15m8
    if (topResponse.isCommitted() && method == null && ! allowForward) {
      IllegalStateException exn;
      exn = new IllegalStateException(L.l("forward() not allowed after buffer has committed."));

      if (cauchoRes == null || ! cauchoRes.hasError()) {
        if (cauchoRes != null)
          cauchoRes.setHasError(true);
        throw exn;
      }

      _webApp.log(exn.getMessage(), exn);

      return;
    } else if ("error".equals(method) || (method == null)) {
      // server/10yg
     
      // } else if ("error".equals(method) || (method == null && ! allowForward)) {
     
      topResponse.resetBuffer();

      if (cauchoRes != null) {
        // server/10yh
        // ServletResponse resp = cauchoRes.getResponse();
        ServletResponse resp = cauchoRes;

        while (resp != null) {
          if (allowForward && resp instanceof IncludeResponse) {
            // server/10yh
            break;
          }
          else if (resp instanceof CauchoResponse) {
            CauchoResponse cr = (CauchoResponse) resp;
            cr.resetBuffer();
            resp = cr.getResponse();
          } else {
            resp.resetBuffer();

            resp = null;
          }
View Full Code Here

  {
    if (_webApp.isAllowForwardAfterFlush()) {
      //
    } else {
      if (res instanceof CauchoResponse) {
        CauchoResponse cauchoResponse = (CauchoResponse) res;
        cauchoResponse.close();

        ServletResponse resp = cauchoResponse.getResponse();

        while(resp != null) {
          if (resp instanceof CauchoResponse) {
            CauchoResponse cr = (CauchoResponse)resp;
            cr.close();
            resp = cr.getResponse();
          } else {
            resp = null;
          }
        }
      } else {
View Full Code Here

TOP

Related Classes of com.caucho.server.http.CauchoResponse

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.