本文整理汇总了Java中org.apache.tomcat.util.buf.ByteChunk.setBytes方法的典型用法代码示例。如果您正苦于以下问题:Java ByteChunk.setBytes方法的具体用法?Java ByteChunk.setBytes怎么用?Java ByteChunk.setBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tomcat.util.buf.ByteChunk
的用法示例。
在下文中一共展示了ByteChunk.setBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Read bytes into the specified chunk.
*/
@Override
public int doRead(ByteChunk chunk, Request req )
throws IOException {
if (pos >= lastValid) {
if (!fill())
return -1;
}
int length = lastValid - pos;
chunk.setBytes(buf, pos, length);
pos = lastValid;
return (length);
}
示例2: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Read bytes into the specified chunk.
*/
@Override
public int doRead(ByteChunk chunk, Request req )
throws IOException {
if (pos >= lastValid) {
if (!fill(true,true)) //read body, must be blocking, as the thread is inside the app
return -1;
}
int length = lastValid - pos;
chunk.setBytes(buf, pos, length);
pos = lastValid;
return (length);
}
示例3: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Read bytes into the specified chunk.
*/
public int doRead(ByteChunk chunk, Request req )
throws IOException {
if (endOfStream) {
return -1;
}
if (first && req.getContentLength() > 0) {
// Handle special first-body-chunk
if (!receive()) {
return 0;
}
} else if (empty) {
if (!refillReadBuffer()) {
return -1;
}
}
ByteChunk bc = bodyBytes.getByteChunk();
chunk.setBytes(bc.getBuffer(), bc.getStart(), bc.getLength());
empty = true;
return chunk.getLength();
}
示例4: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Read bytes into the specified chunk.
*/
public int doRead(ByteChunk chunk, Request req )
throws IOException {
if (pos >= lastValid) {
if (!fill())
return -1;
}
int length = lastValid - pos;
chunk.setBytes(buf, pos, length);
pos = lastValid;
return (length);
}
示例5: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Read bytes into the specified chunk.
*/
@Override
public int doRead(ByteChunk chunk, Request req) throws IOException {
if (endOfStream) {
return -1;
}
if (first && req.getContentLengthLong() > 0) {
// Handle special first-body-chunk
if (!receive()) {
return 0;
}
} else if (empty) {
if (!refillReadBuffer()) {
return -1;
}
}
ByteChunk bc = bodyBytes.getByteChunk();
chunk.setBytes(bc.getBuffer(), bc.getStart(), bc.getLength());
empty = true;
return chunk.getLength();
}
示例6: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Fills the given ByteChunk with the buffered request body.
*/
@Override
public int doRead(ByteChunk chunk, Request request) throws IOException {
if (hasRead || buffered.getLength() <= 0) {
return -1;
}
chunk.setBytes(buffered.getBytes(), buffered.getStart(),
buffered.getLength());
hasRead = true;
return chunk.getLength();
}
示例7: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Read bytes.
*
* @return If the filter does request length control, this value is
* significant; it should be the number of bytes consumed from the buffer,
* up until the end of the current request body, or the buffer length,
* whichever is greater. If the filter does not do request body length
* control, the returned value should be -1.
*/
@Override
public int doRead(ByteChunk chunk, Request req)
throws IOException {
int result = -1;
if (contentLength >= 0) {
if (remaining > 0) {
int nRead = buffer.doRead(chunk, req);
if (nRead > remaining) {
// The chunk is longer than the number of bytes remaining
// in the body; changing the chunk length to the number
// of bytes remaining
chunk.setBytes(chunk.getBytes(), chunk.getStart(),
(int) remaining);
result = (int) remaining;
} else {
result = nRead;
}
if (nRead > 0) {
remaining = remaining - nRead;
}
} else {
// No more bytes left to be read : return -1 and clear the
// buffer
chunk.recycle();
result = -1;
}
}
return result;
}
示例8: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Read bytes into the specified chunk.
*/
@Override
public int doRead(ByteChunk chunk, Request req) throws IOException {
if (pos >= lastValid) {
if (!fill())
return -1;
}
int length = lastValid - pos;
chunk.setBytes(buf, pos, length);
pos = lastValid;
return (length);
}
示例9: doWrite
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Write some bytes.
*
* @return number of bytes written by the filter
*/
@Override
public int doWrite(ByteChunk chunk, Response res)
throws IOException {
int result = -1;
if (contentLength >= 0) {
if (remaining > 0) {
result = chunk.getLength();
if (result > remaining) {
// The chunk is longer than the number of bytes remaining
// in the body; changing the chunk length to the number
// of bytes remaining
chunk.setBytes(chunk.getBytes(), chunk.getStart(),
(int) remaining);
result = (int) remaining;
remaining = 0;
} else {
remaining = remaining - result;
}
buffer.doWrite(chunk, res);
} else {
// No more bytes left to be written : return -1 and clear the
// buffer
chunk.recycle();
result = -1;
}
} else {
// If no content length was set, just write the bytes
buffer.doWrite(chunk, res);
result = chunk.getLength();
}
return result;
}
示例10: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Fills the given ByteChunk with the buffered request body.
*/
@Override
public int doRead(ByteChunk chunk, Request request) throws IOException {
if (hasRead || buffered.getLength() <= 0) {
return -1;
}
chunk.setBytes(buffered.getBytes(), buffered.getStart(), buffered.getLength());
hasRead = true;
return chunk.getLength();
}
示例11: doWrite
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Write some bytes.
*
* @return number of bytes written by the filter
*/
public int doWrite(ByteChunk chunk, Response res)
throws IOException {
int result = -1;
if (contentLength >= 0) {
if (remaining > 0) {
result = chunk.getLength();
if (result > remaining) {
// The chunk is longer than the number of bytes remaining
// in the body; changing the chunk length to the number
// of bytes remaining
chunk.setBytes(chunk.getBytes(), chunk.getStart(),
(int) remaining);
result = (int) remaining;
remaining = 0;
} else {
remaining = remaining - result;
}
buffer.doWrite(chunk, res);
} else {
// No more bytes left to be written : return -1 and clear the
// buffer
chunk.recycle();
result = -1;
}
} else {
// If no content length was set, just write the bytes
buffer.doWrite(chunk, res);
result = chunk.getLength();
}
return result;
}
示例12: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Fills the given ByteChunk with the buffered request body.
*/
public int doRead(ByteChunk chunk, Request request) throws IOException {
if (hasRead || buffered.getLength() <= 0) {
return -1;
} else {
chunk.setBytes(buffered.getBytes(), buffered.getStart(),
buffered.getLength());
hasRead = true;
}
return chunk.getLength();
}
示例13: doWrite
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Write some bytes.
*
* @return number of bytes written by the filter
*/
@Override
public int doWrite(ByteChunk chunk, Response res) throws IOException {
int result = -1;
if (contentLength >= 0) {
if (remaining > 0) {
result = chunk.getLength();
if (result > remaining) {
// The chunk is longer than the number of bytes remaining
// in the body; changing the chunk length to the number
// of bytes remaining
chunk.setBytes(chunk.getBytes(), chunk.getStart(), (int) remaining);
result = (int) remaining;
remaining = 0;
} else {
remaining = remaining - result;
}
buffer.doWrite(chunk, res);
} else {
// No more bytes left to be written : return -1 and clear the
// buffer
chunk.recycle();
result = -1;
}
} else {
// If no content length was set, just write the bytes
buffer.doWrite(chunk, res);
result = chunk.getLength();
}
return result;
}
示例14: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Read bytes.
*
* @return If the filter does request length control, this value is
* significant; it should be the number of bytes consumed from the buffer,
* up until the end of the current request body, or the buffer length,
* whichever is greater. If the filter does not do request body length
* control, the returned value should be -1.
*/
@Override
public int doRead(ByteChunk chunk, Request req) throws IOException {
if (endChunk) {
return -1;
}
checkError();
if(needCRLFParse) {
needCRLFParse = false;
parseCRLF(false);
}
if (remaining <= 0) {
if (!parseChunkHeader()) {
throwIOException(sm.getString("chunkedInputFilter.invalidHeader"));
}
if (endChunk) {
parseEndChunk();
return -1;
}
}
int result = 0;
if (pos >= lastValid) {
if (readBytes() < 0) {
throwIOException(sm.getString("chunkedInputFilter.eos"));
}
}
if (remaining > (lastValid - pos)) {
result = lastValid - pos;
remaining = remaining - result;
chunk.setBytes(buf, pos, result);
pos = lastValid;
} else {
result = remaining;
chunk.setBytes(buf, pos, remaining);
pos = pos + remaining;
remaining = 0;
//we need a CRLF
if ((pos+1) >= lastValid) {
//if we call parseCRLF we overrun the buffer here
//so we defer it to the next call BZ 11117
needCRLFParse = true;
} else {
parseCRLF(false); //parse the CRLF immediately
}
}
return result;
}
示例15: doRead
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Read bytes.
*
* @return If the filter does request length control, this value is
* significant; it should be the number of bytes consumed from the
* buffer, up until the end of the current request body, or the
* buffer length, whichever is greater. If the filter does not do
* request body length control, the returned value should be -1.
*/
@Override
public int doRead(ByteChunk chunk, Request req) throws IOException {
if (endChunk) {
return -1;
}
checkError();
if (needCRLFParse) {
needCRLFParse = false;
parseCRLF(false);
}
if (remaining <= 0) {
if (!parseChunkHeader()) {
throwIOException(sm.getString("chunkedInputFilter.invalidHeader"));
}
if (endChunk) {
parseEndChunk();
return -1;
}
}
int result = 0;
if (pos >= lastValid) {
if (readBytes() < 0) {
throwIOException(sm.getString("chunkedInputFilter.eos"));
}
}
if (remaining > (lastValid - pos)) {
result = lastValid - pos;
remaining = remaining - result;
chunk.setBytes(buf, pos, result);
pos = lastValid;
} else {
result = remaining;
chunk.setBytes(buf, pos, remaining);
pos = pos + remaining;
remaining = 0;
// we need a CRLF
if ((pos + 1) >= lastValid) {
// if we call parseCRLF we overrun the buffer here
// so we defer it to the next call BZ 11117
needCRLFParse = true;
} else {
parseCRLF(false); // parse the CRLF immediately
}
}
return result;
}