Examples of CountingInputStream


Examples of org.apache.commons.io.input.CountingInputStream

        // works OK even if ContentEncoding is null
        boolean gzipped = ENCODING_GZIP.equals(conn.getContentEncoding());
        InputStream instream = null;
        try {
            instream = new CountingInputStream(conn.getInputStream());
            if (gzipped) {
                in = new BufferedInputStream(new GZIPInputStream(instream));
            } else {
                in = new BufferedInputStream(instream);
            }
View Full Code Here

Examples of org.apache.commons.io.input.CountingInputStream

            // Request sent. Now get the response:
            InputStream instream = httpMethod.getResponseBodyAsStream();

            if (instream != null) {// will be null for HEAD
                instream = new CountingInputStream(instream);
                try {
                    Header responseHeader = httpMethod.getResponseHeader(HEADER_CONTENT_ENCODING);
                    if (responseHeader!= null && ENCODING_GZIP.equals(responseHeader.getValue())) {
                        InputStream tmpInput = new GZIPInputStream(instream); // tmp inputstream needs to have a good counting
                        res.setResponseData(readResponse(res, tmpInput, (int) httpMethod.getResponseContentLength()));                       
View Full Code Here

Examples of org.apache.commons.io.input.CountingInputStream

     * @throws IOException if an I/O error occurs.
     */
    public BundleReader(BundleBinding binding, InputStream stream)
            throws IOException {
        this.binding = binding;
        this.cin = new CountingInputStream(stream);
        this.in = new DataInputStream(cin);
        this.version = in.readUnsignedByte();
    }
View Full Code Here

Examples of org.apache.james.mailbox.store.streaming.CountingInputStream

            if (boundary != null) {
                propertyBuilder.setBoundary(boundary);
            }
            if ("text".equalsIgnoreCase(mediaType)) {
                long lines = -1;
                final CountingInputStream bodyStream = new CountingInputStream(parser.getInputStream());
                try {
                    bodyStream.readAll();
                    lines = bodyStream.getLineCount();
                } finally {
                    IOUtils.closeQuietly(bodyStream);
                }

                next = parser.next();
                if (next == MimeTokenStream.T_EPILOGUE) {
                    final CountingInputStream epilogueStream = new CountingInputStream(parser.getInputStream());
                    try {
                        epilogueStream.readAll();
                        lines += epilogueStream.getLineCount();
                    } finally {
                        IOUtils.closeQuietly(epilogueStream);
                    }
                }
                propertyBuilder.setTextualLineCount(lines);
View Full Code Here

Examples of org.apache.james.mailbox.store.streaming.CountingInputStream

            final String boundary = descriptor.getBoundary();
            if (boundary != null) {
                propertyBuilder.setBoundary(boundary);
            }  
            if ("text".equalsIgnoreCase(mediaType)) {
                final CountingInputStream bodyStream = new CountingInputStream(parser.getInputStream());
                bodyStream.readAll();
                long lines = bodyStream.getLineCount();
                bodyStream.close();
                next = parser.next();
                if (next == MimeTokenStream.T_EPILOGUE)  {
                    final CountingInputStream epilogueStream = new CountingInputStream(parser.getInputStream());
                    epilogueStream.readAll();
                    lines+=epilogueStream.getLineCount();
                    epilogueStream.close();

                }
                propertyBuilder.setTextualLineCount(lines);
            }
           
View Full Code Here

Examples of org.apache.james.mailbox.store.streaming.CountingInputStream

        MaximalBodyDescriptor descriptor = (MaximalBodyDescriptor) parser
                .getBodyDescriptor();
        final MimeDescriptorImpl mimeDescriptorImpl;
        if ("message".equalsIgnoreCase(descriptor.getMediaType())
                && "rfc822".equalsIgnoreCase(descriptor.getSubType())) {
            final CountingInputStream messageStream = new CountingInputStream(
                    parser.getDecodedInputStream());
            MimeDescriptorImpl embeddedMessageDescriptor = build(messageStream);
            final int octetCount = messageStream.getOctetCount();
            final int lineCount = messageStream.getLineCount();

            mimeDescriptorImpl = createDescriptor(octetCount, lineCount,
                    descriptor, embeddedMessageDescriptor, headers);
        } else {
            final InputStream body = parser.getInputStream();
View Full Code Here

Examples of org.apache.openejb.server.stream.CountingInputStream

        OutputStream out = null;

        try {
            RequestInfos.initRequestInfo(socket);

            in = new CountingInputStream(socket.getInputStream());
            out = new CountingOutputStream(socket.getOutputStream());

            //TODO: if ssl change to https
            final URI socketURI = new URI("http://" + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort());
            processRequest(socketURI, in, out);
View Full Code Here

Examples of org.apache.openejb.server.stream.CountingInputStream

        byte requestTypeByte = RequestType.NOP_REQUEST.getCode();

        try {

            final RequestInfos.RequestInfo info = RequestInfos.info();
            info.setInputStream(new CountingInputStream(rawIn));

            // Read client Protocol Version
            final CountingInputStream cis = info.getInputStream();
            clientProtocol.readExternal(cis);
            ois = new EjbObjectInputStream(cis);

            // Read ServerMetaData
            final ServerMetaData serverMetaData = new ServerMetaData();
View Full Code Here

Examples of org.apache.openejb.server.stream.CountingInputStream

        }
    }

    private void logRequestResponse(final JNDIRequest req, final JNDIResponse res) {
        final RequestInfos.RequestInfo info = RequestInfos.info();
        final CountingInputStream cis = info.getInputStream();
        final CountingOutputStream cos = info.getOutputStream();

        logger.debug("JNDI REQUEST: " + req + " (size = " + (null != cis ? cis.getCount() : 0)
            + "b, remote-ip =" + info.ip
            + ") -- RESPONSE: " + res + " (size = " + (null != cos ? cos.getCount() : 0) + "b)");
    }
View Full Code Here

Examples of org.apache.tika.io.CountingInputStream

        // Automatically detect the MIME type of the document
        MediaType type = detector.detect(stream, metadata);
        metadata.set(Metadata.CONTENT_TYPE, type.toString());

        // TIKA-216: Zip bomb prevention
        CountingInputStream count = new CountingInputStream(stream);
        SecureContentHandler secure = new SecureContentHandler(handler, count);

        // Parse the document
        try {
            super.parse(count, secure, metadata, context);
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.