Package com.caucho.vfs

Examples of com.caucho.vfs.ReadStream


    if (conn instanceof HttpURLConnection)
      ((HttpURLConnection) conn).setFollowRedirects(true);

    InputStream is = conn.getInputStream();
    try {
      ReadStream in = Vfs.openRead(is);
      String encoding = conn.getContentEncoding();
      String contentType = conn.getContentType();

      if (_charEncoding != null) {
        encoding = _charEncoding;
        if (encoding != null && ! encoding.equals(""))
          in.setEncoding(encoding);
      }
      else if (encoding != null)
        in.setEncoding(encoding);
      else if (contentType != null) {
        int p = contentType.indexOf("charset=");
        if (p > 0) {
          CharBuffer cb = new CharBuffer();
          for (int i = p + 8; i < contentType.length(); i++) {
            int ch = contentType.charAt(i);
            if (ch == '"' || ch == '\'') {
            }
            else if (ch >= 'a' && ch <= 'z')
              cb.append((char) ch);
            else if (ch >= 'A' && ch <= 'Z')
              cb.append((char) ch);
            else if (ch >= '0' && ch <= '9')
              cb.append((char) ch);
            else if (ch == '-' || ch == '_')
              cb.append((char) ch);
            else
              break;
          }
          encoding = cb.toString();

          in.setEncoding(encoding);
        }
      }
     
      JspWriter out = pageContext.getOut();

      int ch;
      while ((ch = in.readChar()) >= 0)
        out.print((char) ch);
    } finally {
      is.close();
    }
  }
View Full Code Here


                                HttpServletResponse res,
                                String uri,
                                ClientSocket stream)
    throws ServletException, IOException
  {
    ReadStream rs = stream.getInputStream();
    WriteStream out = stream.getOutputStream();

    try {
      out.print(req.getMethod());
      out.print(' ');
View Full Code Here

      }
     
      TempBuffer.free(tempBuf);
      tempBuf = null;

      ReadStream rs = Vfs.openRead(inputStream);
      boolean hasStatus = false;

      try {
        hasStatus = parseHeaders(req, res, rs);

        OutputStream out = res.getOutputStream();

        rs.writeToStream(out);
      } finally {
        try {
          rs.close();
        } catch (Throwable e) {
          log.log(Level.FINER, e.toString(), e);

        }
View Full Code Here

  private String []getArgs(String path)
  {
    if (_executable != null)
      return new String[] { _executable, path };

    ReadStream is = null;
    try {
      is = Vfs.lookup(path).openRead();

      int ch;
      if (is.read() != '#')
        return new String[] { path };
      else if (is.read() != '!')
        return new String[] { path };

      CharBuffer cb = CharBuffer.allocate();
      ArrayList<String> list = new ArrayList<String>();
      ch = is.read();

      while ((ch >= 0 && ch != '\r' && ch != '\n')) {
        for (; ch == ' ' || ch == '\t'; ch = is.read()) {
        }

        if (ch < 0 || ch == '\r' || ch == '\n') {
          if (list.size() > 0) {
            list.add(path);
            return list.toArray(new String[list.size()]);
          }
          else
            return new String[] { path };
        }

        cb.clear();
        while (ch > 0 && ch != ' ' && ch != '\t' && ch != '\r' && ch != '\n') {
          cb.append((char) ch);

          ch = is.read();
        }

        list.add(cb.toString());

        for (; ch == ' ' || ch == '\t'; ch = is.read()) {
        }
      }

      if (list.size() > 0) {
        list.add(path);
        return list.toArray(new String[list.size()]);
      }
      else
        return new String[] { path };
    } catch (Exception e) {
      return new String[] { path };
    } finally {
      if (is != null) {
        is.close();
      }
    }
  }
View Full Code Here

  }

  Statement parse(Path path)
    throws IOException
  {
    ReadStream is = path.openRead();

    try {
      ArrayList<Statement> statements = new ArrayList<Statement>();
     
      parse(is, statements);

      return new BlockStatement(statements);
    } finally {
      is.close();
    }
  }
View Full Code Here

    {
      flushBuffer();
     
      _out.close();

      ReadStream is = _tempStream.openRead();
      Statement stmt = null;
      try {
        stmt = new SSIParser(_factory).parse(is);
      } finally {
        is.close();
      }

      try {
        WriteStream out = Vfs.openWrite(res.getOutputStream());
        stmt.apply(out, req, res);
View Full Code Here

        TempStream ts = _xsltStream.getTempStream();

        Document doc = null;
       
        ReadStream is = ts.openRead();
        Path userPath = Vfs.lookup();
        if (req instanceof CauchoRequest)
          userPath.setUserPath(((CauchoRequest) req).getPageURI());
        else
          userPath.setUserPath(req.getRequestURI());
        is.setPath(userPath);

        try {
          doc = new Xml().parseDocument(is);
        } finally {
          is.close();
        }
     
        String href = (String) req.getAttribute("caucho.xsl.stylesheet");

        if (href == null)
View Full Code Here

  private boolean handleInitialRequest()
    throws IOException
  {
    _isFirst = false;
   
    ReadStream is = _rawRead;
   
    int ch = is.read();
   
    if (ch < 0)
      return false;
   
    boolean isUnidir = false;
   
    if (ch == HMUX_TO_UNIDIR_HMTP)
      isUnidir = true;
    else if (ch == HMUX_SWITCH_TO_HMTP)
      isUnidir = false;
    else
      throw new UnsupportedOperationException(L.l("0x{0} is an invalid HMUX code.",
                                                  Integer.toHexString(ch)));

    int len = (is.read() << 8) + is.read();
    int adminCode = is.read();
    boolean isAdmin = adminCode != 0;

    InputStream rawIs = is;
   
    is.skip(len - 1);

    _hmtpReader = new HmtpWebSocketReader(rawIs);

    _hmtpWriter = new HmtpWebSocketWriter(_rawWrite);
    // _hmtpWriter.setId(getRequestId());
View Full Code Here

   * @param url the source url to parse from
   */
  public void parse(String systemId)
    throws IOException, SAXException
  {
    ReadStream is = Vfs.lookup(systemId).openRead();

    _reader = is.getReader();
    _systemId = systemId;
    _filename = systemId;
    try {
      parseImpl();
    } finally {
View Full Code Here

  public static Source convertToSource(Object xmlObj, String systemId)
    throws JspException
  {
    if (xmlObj instanceof String) {
      ReadStream is = Vfs.openString((String) xmlObj);

      return new StreamSource(is, systemId);
    }
    else if (xmlObj instanceof InputStream) {
      return new StreamSource((InputStream) xmlObj, systemId);
View Full Code Here

TOP

Related Classes of com.caucho.vfs.ReadStream

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.