Package com.caucho.server.http

Examples of com.caucho.server.http.CauchoResponse


  {
    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


    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 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

    // 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

  {
    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

    if (request instanceof CauchoRequest)
      req = (CauchoRequest) request;
    else
      req = RequestAdapter.create((HttpServletRequest) request, _webApp);
   
    CauchoResponse res;
    ResponseAdapter resAdapt = null;
   
    if (response instanceof CauchoResponse)
      res = (CauchoResponse) response;
    else {
      resAdapt = ResponseAdapter.create((HttpServletResponse) response);
      res = resAdapt;
    }

    try {
      service(req, res);
    } catch (InterruptedException e) {
      log.log(Level.FINE, e.toString(), e);
     
      log.warning("XTP: interrupted for " + req.getPageURI());
     
      res.sendError(503, "Server busy: XTP generation delayed");
    } finally {
      if (resAdapt != null)
  resAdapt.close();
    }
  }
View Full Code Here

      _bodyOut = null;
    }
    else
      body = BodyContentImpl.allocate();

    CauchoResponse response = getCauchoResponse();

    body.init(_out);

    _out = body;

    response.setForbidForward(true);
    try {
      _bodyResponseStream.flushBuffer();
    } catch (IOException e) {
    }
    _bodyResponseStream.start();
    _bodyResponseStream.setWriter(body);
    _bodyResponseStream.setEncoding(response.getCharacterEncoding());
    response.setResponseStream(_bodyResponseStream);

    return body;
  }
View Full Code Here

   * Returns the top writer.
   */
  public PrintWriter getTopWriter()
    throws IOException
  {
    CauchoResponse response = getCauchoResponse();

    AbstractResponseStream currentStream = response.getResponseStream();

    response.setResponseStream(_responseStream);

    try {
      return response.getWriter();
    } finally {
      response.setResponseStream(currentStream);
    }
  }
View Full Code Here

    HttpServletRequest request = getCauchoRequest();

    request.setAttribute("javax.servlet.jsp.jspException", e);

    CauchoResponse response = getCauchoResponse();

    response.setForbidForward(false);
    response.setResponseStream(_responseStream);
    response.killCache();
    response.setNoCache(true);

    _hasException = true;

    if (e instanceof ClientDisconnectException)
      throw (ClientDisconnectException) e;
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");


        if (statusCode != null) {
          final int status = statusCode.intValue();

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

            throw new JspException(message);
          }
        }
*/
        //jsp/1jif
        int status = response.getStatus();

        if (status < 200 || status > 299) {
          String message = L.l(
            "c:import status code {0} recieved 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);

      disp.include(request, response);

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


      if (statusCode != null) {
        final int status = statusCode.intValue();

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

          throw new JspException(message);
        }
      }
*/
      //jsp/1jie
      int status = response.getStatus();

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