Package javax.servlet

Examples of javax.servlet.ServletInputStream.available()


                                HttpMessage msg = exchange.getIn(HttpMessage.class);

                                ServletInputStream sis = HttpConverter.toServletInputStream(msg);
                                assertNotNull(sis);
                                // The ServletInputStream should be cached and you can't read message here
                                assertTrue(sis.available() == 0);                               
                                String s = msg.getBody(String.class);

                                assertEquals("Hello World", s);
                            }
                        }).transform(constant("Bye World"));
View Full Code Here


                                HttpMessage msg = exchange.getIn(HttpMessage.class);

                                ServletInputStream sis = HttpConverter.toServletInputStream(msg);
                                assertNotNull(sis);
                                // The ServletInputStream should be cached and you can't read message here
                                assertTrue(sis.available() == 0);                               
                                String s = msg.getBody(String.class);

                                assertEquals("Hello World", s);
                            }
                        }).transform(constant("Bye World"));
View Full Code Here

                                HttpMessage msg = exchange.getIn(HttpMessage.class);

                                ServletInputStream sis = HttpConverter.toServletInputStream(msg);
                                assertNotNull(sis);
                                // The ServletInputStream should be cached and you can't read message here
                                assertTrue(sis.available() == 0);                               
                                String s = msg.getBody(String.class);

                                assertEquals("Hello World", s);
                            }
                        }).transform(constant("Bye World"));
View Full Code Here

            if ("POST".equalsIgnoreCase(request.getMethod())) {
                String qs = request.getQueryString();
                if (isNonEmpty(qs) && request.getContentLength() == 3) {
                    ServletInputStream is = request.getInputStream();
                    response.setStatus(HttpServletResponse.SC_OK);
                    byte buf[] = new byte[is.available()];
                    is.readLine(buf, 0, is.available());
                    ServletOutputStream os = response.getOutputStream();
                    os.println(new String(buf));
                    os.flush();
                    os.close();
View Full Code Here

                String qs = request.getQueryString();
                if (isNonEmpty(qs) && request.getContentLength() == 3) {
                    ServletInputStream is = request.getInputStream();
                    response.setStatus(HttpServletResponse.SC_OK);
                    byte buf[] = new byte[is.available()];
                    is.readLine(buf, 0, is.available());
                    ServletOutputStream os = response.getOutputStream();
                    os.println(new String(buf));
                    os.flush();
                    os.close();
                } else {
View Full Code Here

            ServletInputStream is = event.getHttpServletRequest().getInputStream();
            // Using while (true): Not checking if input is available will trigger a blocking
            // read. No other event should be triggered (the current READ event will be in progress
            // until the read timeouts, which will trigger an ERROR event due to an IOException).
            // while (true) {
            while (is.available() > 0) {
                int c = is.read();
                if (c > 0) {
                    System.out.print((char) c);
                } else {
                    System.out.print(c);
View Full Code Here

     */
    public static boolean streamNotConsumed( HttpServletRequest request ) {
        try {
            ServletInputStream servletInputStream = request.getInputStream();
            //in servlet >= 3.0, available will throw an exception (while previously it didn't)
            return request.getContentLength() != 0 && servletInputStream.available() > 0;
        } catch (IOException e) {
            return false;
        }
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.