1 17 18 package org.apache.coyote.http11.filters; 19 20 import java.io.IOException ; 21 22 import org.apache.coyote.InputBuffer; 23 import org.apache.coyote.http11.InputFilter; 24 import org.apache.tomcat.util.buf.ByteChunk; 25 26 30 public class SavedRequestInputFilter implements InputFilter { 31 32 35 protected ByteChunk input = null; 36 37 42 public SavedRequestInputFilter(ByteChunk input) { 43 this.input = input; 44 } 45 46 49 public int doRead(ByteChunk chunk, org.apache.coyote.Request request) 50 throws IOException { 51 int writeLength = 0; 52 53 if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) { 54 writeLength = chunk.getLimit(); 55 } else { 56 writeLength = input.getLength(); 57 } 58 59 if(input.getOffset()>= input.getEnd()) 60 return -1; 61 62 input.substract(chunk.getBuffer(), 0, writeLength); 63 chunk.setOffset(0); 64 chunk.setEnd(writeLength); 65 66 return writeLength; 67 } 68 69 72 public void setRequest(org.apache.coyote.Request request) { 73 request.setContentLength(input.getLength()); 74 } 75 76 79 public void recycle() { 80 input = null; 81 } 82 83 86 public ByteChunk getEncodingName() { 87 return null; 88 } 89 90 93 public void setBuffer(InputBuffer buffer) { 94 } 95 96 99 public long end() throws IOException { 100 return 0; 101 } 102 103 } 104 | Popular Tags |