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


Java ByteChunk.setOffset方法代码示例

本文整理汇总了Java中org.apache.tomcat.util.buf.ByteChunk.setOffset方法的典型用法代码示例。如果您正苦于以下问题:Java ByteChunk.setOffset方法的具体用法?Java ByteChunk.setOffset怎么用?Java ByteChunk.setOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tomcat.util.buf.ByteChunk的用法示例。


在下文中一共展示了ByteChunk.setOffset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doRead

import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
 * Read bytes.
 */
@Override
public int doRead(ByteChunk chunk, org.apache.coyote.Request request)
        throws IOException {
    int writeLength = 0;
    
    if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) {
        writeLength = chunk.getLimit();
    } else {
        writeLength = input.getLength();
    }
    
    if(input.getOffset()>= input.getEnd())
        return -1;
    
    input.substract(chunk.getBuffer(), 0, writeLength);
    chunk.setOffset(0);
    chunk.setEnd(writeLength);
    
    return writeLength;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:SavedRequestInputFilter.java

示例2: doRead

import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
 * Read bytes.
 */
public int doRead(ByteChunk chunk, org.apache.coyote.Request request)
        throws IOException {
    int writeLength = 0;
    
    if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) {
        writeLength = chunk.getLimit();
    } else {
    	writeLength = input.getLength();
    }
    
    if(input.getOffset()>= input.getEnd())
        return -1;
    
    input.substract(chunk.getBuffer(), 0, writeLength);
    chunk.setOffset(0);
    chunk.setEnd(writeLength);
    
    return writeLength;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:SavedRequestInputFilter.java

示例3: doRead

import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
 * Read bytes.
 */
@Override
public int doRead(ByteChunk chunk, org.apache.coyote.Request request) throws IOException {
	int writeLength = 0;

	if (chunk.getLimit() > 0 && chunk.getLimit() < input.getLength()) {
		writeLength = chunk.getLimit();
	} else {
		writeLength = input.getLength();
	}

	if (input.getOffset() >= input.getEnd())
		return -1;

	input.substract(chunk.getBuffer(), 0, writeLength);
	chunk.setOffset(0);
	chunk.setEnd(writeLength);

	return writeLength;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:23,代码来源:SavedRequestInputFilter.java

示例4: doWrite

import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
 * Write chunk.
 */
public int doWrite(ByteChunk chunk, Response res) 
    throws IOException {

    // If non blocking (comet) and there are leftover bytes, 
    // put all remaining bytes in the leftover buffer (they are
    // part of the same write operation)
    if (leftover.getLength() > 0) {
        leftover.append(chunk);
        return chunk.getLength();
    }
    
    int len = chunk.getLength();
    int start = chunk.getStart();
    byte[] b = chunk.getBuffer();
    while (len > 0) {
        int thisTime = len;
        if (bbuf.position() == bbuf.capacity()) {
            flushBuffer();
            if (leftover.getLength() > 0) {
                // If non blocking (comet) and there are leftover bytes, 
                // put all remaining bytes in the leftover buffer (they are
                // part of the same write operation)
                int oldStart = chunk.getOffset();
                chunk.setOffset(start);
                leftover.append(chunk);
                chunk.setOffset(oldStart);
                // After that, all content has been "written"
                return chunk.getLength();
            }
        }
        if (thisTime > bbuf.capacity() - bbuf.position()) {
            thisTime = bbuf.capacity() - bbuf.position();
        }
        bbuf.put(b, start, thisTime);
        len = len - thisTime;
        start = start + thisTime;
    }
    return chunk.getLength();

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

示例5: authenticate

import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
 * Authenticate the user making this request, based on the specified login
 * configuration. Return <code>true</code> if any specified constraint has
 * been satisfied, or <code>false</code> if we have created a response
 * challenge already.
 *
 * @param request
 *            Request we are processing
 * @param response
 *            Response we are creating
 * @param config
 *            Login configuration describing how authentication should be
 *            performed
 *
 * @exception IOException
 *                if an input/output error occurs
 */
@Override
public boolean authenticate(Request request, HttpServletResponse response, LoginConfig config) throws IOException {

	if (checkForCachedAuthentication(request, response, true)) {
		return true;
	}

	// Validate any credentials already included with this request
	String username = null;
	String password = null;

	MessageBytes authorization = request.getCoyoteRequest().getMimeHeaders().getValue("authorization");

	if (authorization != null) {
		authorization.toBytes();
		ByteChunk authorizationBC = authorization.getByteChunk();
		if (authorizationBC.startsWithIgnoreCase("basic ", 0)) {
			authorizationBC.setOffset(authorizationBC.getOffset() + 6);

			byte[] decoded = Base64.decodeBase64(authorizationBC.getBuffer(), authorizationBC.getOffset(),
					authorizationBC.getLength());

			// Get username and password
			int colon = -1;
			for (int i = 0; i < decoded.length; i++) {
				if (decoded[i] == ':') {
					colon = i;
					break;
				}
			}

			if (colon < 0) {
				username = new String(decoded, B2CConverter.ISO_8859_1);
			} else {
				username = new String(decoded, 0, colon, B2CConverter.ISO_8859_1);
				password = new String(decoded, colon + 1, decoded.length - colon - 1, B2CConverter.ISO_8859_1);
			}

			authorizationBC.setOffset(authorizationBC.getOffset() - 6);
		}

		Principal principal = context.getRealm().authenticate(username, password);
		if (principal != null) {
			register(request, response, principal, HttpServletRequest.BASIC_AUTH, username, password);
			return (true);
		}
	}

	StringBuilder value = new StringBuilder(16);
	value.append("Basic realm=\"");
	if (config.getRealmName() == null) {
		value.append(REALM_NAME);
	} else {
		value.append(config.getRealmName());
	}
	value.append('\"');
	response.setHeader(AUTH_HEADER_NAME, value.toString());
	response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
	return (false);

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


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