Package org.apache.tomcat.util.buf

Examples of org.apache.tomcat.util.buf.ByteChunk


       }
      
       request.getCoyoteRequest().getParameters().recycle();
      
       if ("POST".equalsIgnoreCase(saved.getMethod())) {
           ByteChunk body = saved.getBody();
          
           if (body != null) {
               request.getCoyoteRequest().action
                   (ActionCode.ACTION_REQ_SET_BODY_REPLAY, body);
  
View Full Code Here


           Locale locale = (Locale) locales.nextElement();
           saved.addLocale(locale);
       }

       if ("POST".equalsIgnoreCase(request.getMethod())) {
           ByteChunk body = new ByteChunk();
           body.setLimit(request.getConnector().getMaxSavePostSize());

           byte[] buffer = new byte[4096];
           int bytesRead;
           InputStream is = request.getInputStream();
      
           while ( (bytesRead = is.read(buffer) ) >= 0) {
               body.append(buffer, 0, bytesRead);
           }
           saved.setBody(body);
           saved.setContentType(request.getContentType());
       }
View Full Code Here

      Connector connector = new Connector("org.apache.coyote.memory.MemoryProtocolHandler");
      MemoryProtocolHandler handler = (MemoryProtocolHandler) connector.getProtocolHandler();
      server.invoke(name, "addConnector", new Object[] { connector }, new String[] { Connector.class.getName() });
      try
      {
         ByteChunk input = new ByteChunk(1024);
         ByteChunk output = new ByteChunk(1024);
         org.apache.coyote.Request req = new org.apache.coyote.Request();
         req.decodedURI().setString("/webbmtcleanuptest/test1.jsp");
         req.method().setString("GET");
         org.apache.coyote.Response resp = new org.apache.coyote.Response();
         handler.process(req, input, resp, output);
         if (resp.getStatus() != 200)
            throw new Error(output.toString());

         input = new ByteChunk(1024);
         output = new ByteChunk(1024);
         req = new org.apache.coyote.Request();
         req.decodedURI().setString("/webbmtcleanuptest/test2.jsp");
         req.method().setString("GET");
         resp = new org.apache.coyote.Response();
         handler.process(req, input, resp, output);
         if (resp.getStatus() != 200)
            throw new Error(output.toString());
      }
      finally
      {
         try
         {
View Full Code Here

            throws IOException {
        MessageBytes authorization =
            request.getCoyoteRequest().getMimeHeaders().getValue("authorization");
        if (authorization != null) {
            authorization.toBytes();
            ByteChunk authorizationBC = authorization.getByteChunk();
            if (authorizationBC.startsWithIgnoreCase("basic ", 0)) {
                return bc.authenticate(request, response, config);
            }
            else if (authorizationBC.startsWithIgnoreCase("oauth ", 0)) {
                return authenticateOAuth(request, response, config);
            }
        }

        return false;
View Full Code Here

        // app dir is relative to server home
        tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

        tomcat.start();

        ByteChunk res = getUrl("http://localhost:" + getPort() +
                "/test/bug45nnn/bug45427.jsp");

        String result = res.toString();
        // Warning: JSP attribute escaping != Java String escaping
        assertEcho(result, "00-hello world");
        assertEcho(result, "01-hello 'world");
        assertEcho(result, "02-hello \"world");
        assertEcho(result, "03-hello world");
View Full Code Here

        // app dir is relative to server home
        tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

        tomcat.start();

        ByteChunk res = getUrl("http://localhost:" + getPort() +
                "/test/bug45nnn/bug45451a.jsp");

        String result = res.toString();
        // Warning: JSP attribute escaping != Java String escaping
        assertEcho(result, "00-\\'hello world\\'");
        assertEcho(result, "01-\\'hello world\\'");
        assertEcho(result, "02-\\'hello world\\'");
        assertEcho(result, "03-\\'hello world\\'");

        res = getUrl("http://localhost:" + getPort() + "/test/bug45nnn/bug45451b.jsp");
        result = res.toString();
        // Warning: JSP attribute escaping != Java String escaping
        // Warning: Attributes are always unescaped before passing to the EL
        //          processor
        assertEcho(result, "00-2");
        assertEcho(result, "01-${1+1}");
        assertEcho(result, "02-\\${1+1}");
        assertEcho(result, "03-\\\\${1+1}");
        assertEcho(result, "04-2");
        assertEcho(result, "05-${1+1}");
        assertEcho(result, "06-\\2");
        assertEcho(result, "07-\\${1+1}");
        assertEcho(result, "08-\\\\2");
        assertEcho(result, "09-2");
        assertEcho(result, "10-#{1+1}");
        assertEcho(result, "11-\\2");
        assertEcho(result, "12-\\#{1+1}");
        assertEcho(result, "13-\\\\2");

        res = getUrl("http://localhost:" + getPort() + "/test/bug45nnn/bug45451c.jsp");
        result = res.toString();
        // Warning: JSP attribute escaping != Java String escaping
        // TODO - Currently we allow a single unescaped \ in attribute values
        //        Review if this should cause a warning/error
        assertEcho(result, "00-${1+1}");
        assertEcho(result, "01-\\${1+1}");
        assertEcho(result, "02-\\\\${1+1}");
        assertEcho(result, "03-\\\\\\${1+1}");
        assertEcho(result, "04-${1+1}");
        assertEcho(result, "05-\\${1+1}");
        assertEcho(result, "06-\\${1+1}");
        assertEcho(result, "07-\\\\${1+1}");
        assertEcho(result, "08-\\\\${1+1}");
        assertEcho(result, "09-#{1+1}");
        assertEcho(result, "10-\\#{1+1}");
        assertEcho(result, "11-\\#{1+1}");
        assertEcho(result, "12-\\\\#{1+1}");
        assertEcho(result, "13-\\\\#{1+1}");

        res = getUrl("http://localhost:" + getPort() + "/test/bug45nnn/bug45451d.jspx");
        result = res.toString();
        // Warning: JSP attribute escaping != Java String escaping
        // \\ Is *not* an escape sequence in XML attributes
        assertEcho(result, "00-2");
        assertEcho(result, "01-${1+1}");
        assertEcho(result, "02-\\${1+1}");
        assertEcho(result, "03-\\\\${1+1}");
        assertEcho(result, "04-2");
        assertEcho(result, "05-${1+1}");
        assertEcho(result, "06-\\${1+1}");
        assertEcho(result, "07-\\\\${1+1}");
        assertEcho(result, "08-\\\\\\${1+1}");
        assertEcho(result, "09-2");
        assertEcho(result, "10-#{1+1}");
        assertEcho(result, "11-\\#{1+1}");
        assertEcho(result, "12-\\\\#{1+1}");
        assertEcho(result, "13-\\\\\\#{1+1}");

        res = getUrl("http://localhost:" + getPort() + "/test/bug45nnn/bug45451e.jsp");
        result = res.toString();
        // Warning: JSP attribute escaping != Java String escaping
        // Warning: Attributes are always unescaped before passing to the EL
        //          processor
        assertEcho(result, "00-2");
        assertEcho(result, "01-${1+1}");
View Full Code Here

            public int read() throws IOException {
                return is.read();
            }

            public String read(int len) throws IOException {
                ByteChunk bc = new ByteChunk(125);
                CharChunk cc = new CharChunk(125);
                int read = 0;
                while (read < len) {
                    read = read + is.read(bc.getBytes(), read, len - read);
                }

                bc.setEnd(len);
                b2c.convert(bc, cc, true);
                return cc.toString();
            }
View Full Code Here

        // app dir is relative to server home
        tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

        tomcat.start();

        ByteChunk res = getUrl("http://localhost:" + getPort() +
                "/test/bug45nnn/bug45511.jsp");

        String result = res.toString();
        assertEcho(result, "00-true");
        assertEcho(result, "01-false");
    }
View Full Code Here

                b2c.convert(bc, cc, true);
                return cc.toString();
            }

            public String readLine() throws IOException {
                ByteChunk bc = new ByteChunk(125);
                CharChunk cc = new CharChunk(125);
                int i = is.read();
                int read = 0;
                while (i != -1) {
                    if (i != '\r' && i != '\n') {
                        bc.append((byte)i);
                        read++;
                    } else if (i == '\n') {
                        break;
                    } else if (i == '\r') {
                        if (markSupported) {
                            is.mark(2);
                        }
                        i = read();
                        if (i == -1) {
                            break;
                        } else {
                            if (i == '\n') {
                                break;
                            } else {
                                if (markSupported) {
                                    is.reset();
                                }
                            }
                        }
                    }
                    i = is.read();
                }
                bc.setEnd(read);
                b2c.convert(bc, cc, true);
                return cc.toString();
            }
View Full Code Here

        // app dir is relative to server home
        tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

        tomcat.start();

        ByteChunk res = getUrl("http://localhost:" + getPort() +
                "/test/bug46596.jsp");
        String result = res.toString();
        assertEcho(result, "{OK}");
    }
View Full Code Here

TOP

Related Classes of org.apache.tomcat.util.buf.ByteChunk

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.