/** * End the current request. */ public long end() throws IOException { // Consume extra bytes : parse the stream until the end chunk is found while (doRead(readChunk, null) > 0) { } // Return the number of extra bytes which were consumed return (lastValid - pos); }
return -1; checkError(); parseCRLF(); if (!parseChunkHeader()) { return 0; parseEndChunk(); return -1; readBytes(); parseCRLF(); //parse the CRLF immediately
/** * Parse end chunk data. * @throws IOException Error propagation */ protected void parseEndChunk() throws IOException { // Handle optional trailer headers while (parseHeader()) { // Loop until we run out of headers } }
/** * End the current request. */ @Override public long end() throws IOException { long swallowed = 0; int read = 0; // Consume extra bytes : parse the stream until the end chunk is found while ((read = doRead(this)) >= 0) { swallowed += read; if (maxSwallowSize > -1 && swallowed > maxSwallowSize) { throwIOException(sm.getString("inputFilter.maxSwallow")); } } // Return the number of extra bytes which were consumed return readChunk.remaining(); }
protected void initializeFilters() { // Create and add the identity filters. inputBuffer.addFilter(new IdentityInputFilter()); outputBuffer.addFilter(new IdentityOutputFilter()); // Create and add the chunked filters. inputBuffer.addFilter(new ChunkedInputFilter()); outputBuffer.addFilter(new ChunkedOutputFilter()); // Create and add the void filters. inputBuffer.addFilter(new VoidInputFilter()); outputBuffer.addFilter(new VoidOutputFilter()); // Create and add the chunked filters. // inputBuffer.addFilter(new GzipInputFilter()); outputBuffer.addFilter(new GzipOutputFilter()); }
if (readBytes() <= 0) return false;
if (readBytes() <= 0) return false; parseCRLF(false); eol = true; } else if (chr == Constants.SEMI_COLON && !extension) { throwIOException(sm.getString("chunkedInputFilter.maxExtension"));
if (readBytes() <0) { throwEOFException(sm.getString("chunkedInputFilter.eosTrailer")); parseCRLF(false); return false; if (readBytes() <0) { throwEOFException(sm.getString("chunkedInputFilter.eosTrailer")); if (readBytes() <0) { throwEOFException(sm.getString("chunkedInputFilter.eosTrailer")); throwIOException(sm.getString("chunkedInputFilter.maxTrailer")); if (readBytes() <0) { throwEOFException(sm.getString("chunkedInputFilter.eosTrailer")); parseCRLF(true); eol = true; } else if (chr == Constants.SP) { if (readBytes() <0) { throwEOFException(sm.getString("chunkedInputFilter.eosTrailer"));
/** * Parse end chunk data. * FIXME: Handle trailers */ protected boolean parseEndChunk() throws IOException { return parseCRLF(); // FIXME }
if (readBytes() <= 0) { throwIOException(sm.getString("chunkedInputFilter.invalidCrlfNoData")); if (chr == Constants.CR) { if (crfound) { throwIOException(sm.getString("chunkedInputFilter.invalidCrlfCRCR")); throwIOException(sm.getString("chunkedInputFilter.invalidCrlfNoCR")); throwIOException(sm.getString("chunkedInputFilter.invalidCrlf"));
/** * Initialize standard input and output filters. */ protected void initializeFilters() { // Create and add the identity filters. inputBuffer.addFilter(new IdentityInputFilter()); outputBuffer.addFilter(new IdentityOutputFilter()); // Create and add the chunked filters. inputBuffer.addFilter(new ChunkedInputFilter()); outputBuffer.addFilter(new ChunkedOutputFilter()); // Create and add the void filters. inputBuffer.addFilter(new VoidInputFilter()); outputBuffer.addFilter(new VoidOutputFilter()); // Create and add the chunked filters. //inputBuffer.addFilter(new GzipInputFilter()); outputBuffer.addFilter(new GzipOutputFilter()); }
/** * Parse CRLF at end of chunk. */ protected boolean parseCRLF() throws IOException { boolean eol = false; boolean crfound = false; while (!eol) { if (pos >= lastValid) { if (readBytes() <= 0) throw new IOException("Invalid CRLF"); } if (buf[pos] == Constants.CR) { if (crfound) throw new IOException("Invalid CRLF, two CR characters encountered."); crfound = true; } else if (buf[pos] == Constants.LF) { if (!crfound) throw new IOException("Invalid CRLF, no CR character encountered."); eol = true; } else { throw new IOException("Invalid CRLF"); } pos++; } return true; }
/** * Parse end chunk data. * FIXME: Handle trailers */ protected boolean parseEndChunk() throws IOException { return parseCRLF(); // FIXME }
needCRLFParse = false; parseCRLF(); if (!parseChunkHeader()) { return 0; parseEndChunk(); return -1; readBytes(); parseCRLF(); //parse the CRLF immediately
/** * Initialize standard input and output filters. */ protected void initializeFilters() { // Create and add the identity filters. inputBuffer.addFilter(new IdentityInputFilter()); outputBuffer.addFilter(new IdentityOutputFilter()); // Create and add the chunked filters. inputBuffer.addFilter(new ChunkedInputFilter()); outputBuffer.addFilter(new ChunkedOutputFilter()); // Create and add the void filters. inputBuffer.addFilter(new VoidInputFilter()); outputBuffer.addFilter(new VoidOutputFilter()); // Create and add the chunked filters. //inputBuffer.addFilter(new GzipInputFilter()); outputBuffer.addFilter(new GzipOutputFilter()); }
if (readBytes() <0) throw new EOFException("Unexpected end of stream whilst reading trailer headers for chunked request"); parseCRLF(false); return false; if (readBytes() <0) throw new EOFException("Unexpected end of stream whilst reading trailer headers for chunked request"); if (readBytes() <0) throw new EOFException("Unexpected end of stream whilst reading trailer headers for chunked request"); if (readBytes() <0) throw new EOFException("Unexpected end of stream whilst reading trailer headers for chunked request"); parseCRLF(true); eol = true; } else if (chr == Constants.SP) { if (readBytes() <0) throw new EOFException("Unexpected end of stream whilst reading trailer headers for chunked request");
/** * Parse CRLF at end of chunk. */ protected boolean parseCRLF() throws IOException { boolean eol = false; boolean crfound = false; while (!eol) { if (pos >= lastValid) { if (readBytes() <= 0) throw new IOException("Invalid CRLF"); } if (buf[pos] == Constants.CR) { if (crfound) throw new IOException("Invalid CRLF, two CR characters encountered."); crfound = true; } else if (buf[pos] == Constants.LF) { if (!crfound) throw new IOException("Invalid CRLF, no CR character encountered."); eol = true; } else { throw new IOException("Invalid CRLF"); } pos++; } return true; }
/** * End the current request. */ public long end() throws IOException { // Consume extra bytes : parse the stream until the end chunk is found while (doRead(readChunk, null) >= 0) { } // Return the number of extra bytes which were consumed return (lastValid - pos); }