Package javax.servlet

Examples of javax.servlet.ServletInputStream


    public void tearDown() throws Exception {
    }

    @Test
    public void testDecode() throws IOException, SAXException {
        ServletInputStream input = new ServletInputStreamMock("<body rid='3549788615' xmlns='http://jabber.org/protocol/httpbind' to='vysper.org' xml:lang='en' wait='60' hold='1' ver='1.6' xmpp:version='1.0' xmlns:xmpp='urn:xmpp:xbosh'/>");
        expect(request.getInputStream()).andReturn(input);
        Capture<Stanza> captured = new Capture<Stanza>();
        boshHandler.process(EasyMock.<HttpServletRequest>notNull(), EasyMock.<Stanza>capture(captured));
        mocksControl.replay();
        boshDecoder.decode();
View Full Code Here


        if (encoding==null)
            encoding=StringUtil.__ISO_8859_1;
       
        if (_reader==null || !encoding.equalsIgnoreCase(_readerEncoding))
        {
            final ServletInputStream in = getInputStream();
            _readerEncoding=encoding;
            _reader=new BufferedReader(new InputStreamReader(in,encoding))
            {
                public void close() throws IOException
                {
                    in.close();
                }  
            };
        }
        _inputState=__READER;
        return _reader;
View Full Code Here

        HttpServletResponse response, String serverName) {
        int length = request.getContentLength();

        if (length > 0) {
            try {
                ServletInputStream sis = request.getInputStream();
                HttpTunnelPacket p = new HttpTunnelPacket();
                p.readPacket(sis);

                linkTable.sendPacket(p, serverName);
            } catch (Exception e) {
View Full Code Here

        if (length > 0) {
            HttpTunnelPacket p = null;

            try {
                ServletInputStream sis = request.getInputStream();
                p = new HttpTunnelPacket();
                p.readPacket(sis);
            } catch (Exception e) {
                return;
            }
View Full Code Here

            base_request.setHandled( true );

            File file = new File( resourceBase, URLDecoder.decode( request.getPathInfo() ) );
            file.getParentFile().mkdirs();
            FileOutputStream out = new FileOutputStream( file );
            ServletInputStream in = request.getInputStream();
            try
            {
                IOUtil.copy( in, out );
            }
            finally
            {
                in.close();
                out.close();
            }
            putCallNumber++;
            DeployedResource deployedResource = new DeployedResource();
View Full Code Here

            try {
                int max = getContentLength();
                int len = 0;
                byte buf[] = new byte[getContentLength()];
                ServletInputStream is = getInputStream();
                while (len < max) {
                    int next = is.read(buf, len, max - len);
                    if (next < 0 ) {
                        break;
                    }
                    len += next;
                }
                is.close();
                if (len < max) {
                    // FIX ME, mod_jk when sending an HTTP POST will sometimes
                    // have an actual content length received < content length.
                    // Checking for a read of -1 above prevents this code from
                    // going into an infinite loop.  But the bug must be in mod_jk.
View Full Code Here

     */
    protected void uploadWar(HttpServletRequest request, File war)
        throws IOException {

        war.delete();
        ServletInputStream istream = null;
        BufferedOutputStream ostream = null;
        try {
            istream = request.getInputStream();
            ostream =
                new BufferedOutputStream(new FileOutputStream(war), 1024);
            byte buffer[] = new byte[1024];
            while (true) {
                int n = istream.read(buffer);
                if (n < 0) {
                    break;
                }
                ostream.write(buffer, 0, n);
            }
            ostream.flush();
            ostream.close();
            ostream = null;
            istream.close();
            istream = null;
        } catch (IOException e) {
            war.delete();
            throw e;
        } finally {
            if (ostream != null) {
                try {
                    ostream.close();
                } catch (Throwable t) {
                    ;
                }
                ostream = null;
            }
            if (istream != null) {
                try {
                    istream.close();
                } catch (Throwable t) {
                    ;
                }
                istream = null;
            }
View Full Code Here

                final String expectedContentType = OAuth.ContentType.JSON;
                if (!OAuthUtils.hasContentType(contentType, expectedContentType)) {
                    return;
                }

                final ServletInputStream inputStream = request.getInputStream();
                if (inputStream == null) {
                    return;
                }
                final String jsonString = OAuthUtils.saveStreamAsString(inputStream);
                body = new JSONObject(jsonString);
View Full Code Here

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
            IOException {

        // Read the command directly from the reader, assuming UTF8 encoding
        ServletInputStream sis = request.getInputStream();
        Command command = (Command) wireFormat.unmarshalText(new InputStreamReader(sis, "UTF-8"));

        if (command instanceof WireFormatInfo) {
            WireFormatInfo info = (WireFormatInfo) command;
            if (!canProcessWireFormatVersion(info.getVersion())) {
View Full Code Here

        return ByteBuffer.wrap(binBody).asReadOnlyBuffer();
    }

    private byte[] readBody() {
        try {
            ServletInputStream is = request.getInputStream();
            int length = request.getContentLength();
            byte[] ba;
            if (length < 0)
                ba = ByteStreams.toByteArray(is);
            else {
View Full Code Here

TOP

Related Classes of javax.servlet.ServletInputStream

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.