Package org.apache.http

Examples of org.apache.http.MalformedChunkCodingException


                return;
            }
            int cr = this.buffer.read();
            int lf = this.buffer.read();
            if (cr != HTTP.CR || lf != HTTP.LF) {
                throw new MalformedChunkCodingException("CRLF expected at end of chunk");
            }
            this.endOfChunk = false;
        }
        if (this.lineBuf == null) {
            this.lineBuf = new CharArrayBuffer(32);
        } else {
            this.lineBuf.clear();
        }
        if (this.buffer.readLine(this.lineBuf, this.endOfStream)) {
            int separator = this.lineBuf.indexOf(';');
            if (separator < 0) {
                separator = this.lineBuf.length();
            }
            try {
                String s = this.lineBuf.substringTrimmed(0, separator);
                this.chunkSize = Integer.parseInt(s, 16);
            } catch (NumberFormatException e) {
                throw new MalformedChunkCodingException("Bad chunk header");
            }
            this.pos = 0;
        }
    }
View Full Code Here


                    }
                }
                int maxLen = this.chunkSize - this.pos;
                int len = this.buffer.read(dst, maxLen);
                if (maxLen > 0 && len == 0 && this.endOfStream) {
                    throw new MalformedChunkCodingException("Truncated chunk");
                }
                this.pos += len;
                totalRead += len;
               
                if (this.pos == this.chunkSize) {
View Full Code Here

        int bytesRead = in.read(b, off, len);
        if (bytesRead != -1) {
            pos += bytesRead;
            return bytesRead;
        } else {
            throw new MalformedChunkCodingException("Truncated chunk");
        }
    }
View Full Code Here

     * @throws IOException in case of an I/O error
     */
    private void nextChunk() throws IOException {
        chunkSize = getChunkSize();
        if (chunkSize < 0) {
            throw new MalformedChunkCodingException("Negative chunk size");
        }
        bof = false;
        pos = 0;
        if (chunkSize == 0) {
            eof = true;
View Full Code Here

        // skip CRLF
        if (!bof) {
            int cr = in.read();
            int lf = in.read();
            if ((cr != HTTP.CR) || (lf != HTTP.LF)) {
                throw new MalformedChunkCodingException(
                    "CRLF expected at end of chunk");
            }
        }
        //parse data
        this.buffer.clear();
        int i = this.in.readLine(this.buffer);
        if (i == -1) {
            return 0;
        }
        int separator = this.buffer.indexOf(';');
        if (separator < 0) {
            separator = this.buffer.length();
        }
        try {
            return Integer.parseInt(this.buffer.substringTrimmed(0, separator), 16);
        } catch (NumberFormatException e) {
            throw new MalformedChunkCodingException("Bad chunk header");
        }
    }
View Full Code Here

    private void parseTrailerHeaders() throws IOException {
        try {
            this.footers = AbstractMessageParser.parseHeaders
                (in, -1, -1, null);
        } catch (HttpException e) {
            IOException ioe = new MalformedChunkCodingException("Invalid footer: "
                    + e.getMessage());
            ExceptionUtils.initCause(ioe, e);
            throw ioe;
        }
    }
View Full Code Here

            new ChunkedInputStream((SessionInputBuffer)null);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
        }
        new MalformedChunkCodingException();
        new MalformedChunkCodingException("");
    }
View Full Code Here

        int bytesRead = in.read(b, off, len);
        if (bytesRead != -1) {
            pos += bytesRead;
            return bytesRead;
        } else {
            throw new MalformedChunkCodingException("Truncated chunk");
        }
    }
View Full Code Here

     * @throws IOException in case of an I/O error
     */
    private void nextChunk() throws IOException {
        chunkSize = getChunkSize();
        if (chunkSize < 0) {
            throw new MalformedChunkCodingException("Negative chunk size");
        }
        bof = false;
        pos = 0;
        if (chunkSize == 0) {
            eof = true;
View Full Code Here

        // skip CRLF
        if (!bof) {
            int cr = in.read();
            int lf = in.read();
            if ((cr != HTTP.CR) || (lf != HTTP.LF)) {
                throw new MalformedChunkCodingException(
                    "CRLF expected at end of chunk");
            }
        }
        //parse data
        this.buffer.clear();
        int i = this.in.readLine(this.buffer);
        if (i == -1) {
            return 0;
        }
        int separator = this.buffer.indexOf(';');
        if (separator < 0) {
            separator = this.buffer.length();
        }
        try {
            return Integer.parseInt(this.buffer.substringTrimmed(0, separator), 16);
        } catch (NumberFormatException e) {
            throw new MalformedChunkCodingException("Bad chunk header");
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.http.MalformedChunkCodingException

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.