当前位置: 首页>>代码示例>>Java>>正文


Java ByteChunk.setBytes方法代码示例

本文整理汇总了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);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:InternalAprInputBuffer.java

示例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);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:InternalNioInputBuffer.java

示例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();

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:AjpProcessor.java

示例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);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:InternalAprInputBuffer.java

示例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();

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:26,代码来源:AbstractAjpProcessor.java

示例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();
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:15,代码来源:BufferedInputFilter.java

示例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;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:43,代码来源:IdentityInputFilter.java

示例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);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:18,代码来源:InternalInputBuffer.java

示例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;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:42,代码来源:IdentityOutputFilter.java

示例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();
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:14,代码来源:BufferedInputFilter.java

示例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;

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:IdentityOutputFilter.java

示例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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:BufferedInputFilter.java

示例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;

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:40,代码来源:IdentityOutputFilter.java

示例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;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:63,代码来源:ChunkedInputFilter.java

示例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;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:63,代码来源:ChunkedInputFilter.java


注:本文中的org.apache.tomcat.util.buf.ByteChunk.setBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。