本文整理汇总了Java中org.apache.tomcat.util.buf.ByteChunk.indexOf方法的典型用法代码示例。如果您正苦于以下问题:Java ByteChunk.indexOf方法的具体用法?Java ByteChunk.indexOf怎么用?Java ByteChunk.indexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tomcat.util.buf.ByteChunk
的用法示例。
在下文中一共展示了ByteChunk.indexOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: unescapeDoubleQuotes
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Unescapes any double quotes in the given cookie value.
*
* @param bc The cookie value to modify
*/
private static void unescapeDoubleQuotes(ByteChunk bc) {
if (bc == null || bc.getLength() == 0 || bc.indexOf('"', 0) == -1) {
return;
}
int src = bc.getStart();
int end = bc.getEnd();
int dest = src;
byte[] buffer = bc.getBuffer();
while (src < end) {
if (buffer[src] == '\\' && src < end && buffer[src+1] == '"') {
src++;
}
buffer[dest] = buffer[src];
dest ++;
src ++;
}
bc.setEnd(dest);
}
示例2: unescapeDoubleQuotes
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Unescapes any double quotes in the given cookie value.
*
* @param bc The cookie value to modify
*/
public static void unescapeDoubleQuotes(ByteChunk bc) {
if (bc == null || bc.getLength() == 0 || bc.indexOf('"', 0) == -1) {
return;
}
int src = bc.getStart();
int end = bc.getEnd();
int dest = src;
byte[] buffer = bc.getBuffer();
while (src < end) {
if (buffer[src] == '\\' && src < end && buffer[src+1] == '"') {
src++;
}
buffer[dest] = buffer[src];
dest ++;
src ++;
}
bc.setEnd(dest);
}
示例3: unescapeDoubleQuotes
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Unescapes any double quotes in the given cookie value.
*
* @param bc
* The cookie value to modify
*/
private static void unescapeDoubleQuotes(ByteChunk bc) {
if (bc == null || bc.getLength() == 0 || bc.indexOf('"', 0) == -1) {
return;
}
int src = bc.getStart();
int end = bc.getEnd();
int dest = src;
byte[] buffer = bc.getBuffer();
while (src < end) {
if (buffer[src] == '\\' && src < end && buffer[src + 1] == '"') {
src++;
}
buffer[dest] = buffer[src];
dest++;
src++;
}
bc.setEnd(dest);
}
示例4: parseSessionId
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
/**
* Parse session id in URL.
*/
protected void parseSessionId(org.apache.coyote.Request req, Request request) {
ByteChunk uriBC = req.requestURI().getByteChunk();
int semicolon = uriBC.indexOf(match, 0, match.length(), 0);
if (semicolon > 0) {
// Parse session ID, and extract it from the decoded request URI
int start = uriBC.getStart();
int end = uriBC.getEnd();
int sessionIdStart = semicolon + match.length();
int semicolon2 = uriBC.indexOf(';', sessionIdStart);
if (semicolon2 >= 0) {
request.setRequestedSessionId
(new String(uriBC.getBuffer(), start + sessionIdStart,
semicolon2 - sessionIdStart));
// Extract session ID from request URI
byte[] buf = uriBC.getBuffer();
for (int i = 0; i < end - start - semicolon2; i++) {
buf[start + semicolon + i]
= buf[start + i + semicolon2];
}
uriBC.setBytes(buf, start, end - start - semicolon2 + semicolon);
} else {
request.setRequestedSessionId
(new String(uriBC.getBuffer(), start + sessionIdStart,
(end - start) - sessionIdStart));
uriBC.setEnd(start + semicolon);
}
request.setRequestedSessionURL(true);
} else {
request.setRequestedSessionId(null);
request.setRequestedSessionURL(false);
}
}
示例5: processParameters
import org.apache.tomcat.util.buf.ByteChunk; //导入方法依赖的package包/类
public void processParameters(byte bytes[], int start, int len, String enc) {
int end = start + len;
int pos = start;
if (debug > 0)
log("Bytes: " + new String(bytes, start, len));
do {
boolean noEq = false;
int valStart = -1;
int valEnd = -1;
int nameStart = pos;
int nameEnd = ByteChunk.indexOf(bytes, nameStart, end, '=');
// Workaround for a&b&c encoding
int nameEnd2 = ByteChunk.indexOf(bytes, nameStart, end, '&');
if ((nameEnd2 != -1) && (nameEnd == -1 || nameEnd > nameEnd2)) {
nameEnd = nameEnd2;
noEq = true;
valStart = nameEnd;
valEnd = nameEnd;
if (debug > 0)
log("no equal " + nameStart + " " + nameEnd + " "
+ new String(bytes, nameStart, nameEnd - nameStart));
}
if (nameEnd == -1)
nameEnd = end;
if (!noEq) {
valStart = (nameEnd < end) ? nameEnd + 1 : end;
valEnd = ByteChunk.indexOf(bytes, valStart, end, '&');
if (valEnd == -1)
valEnd = (valStart < end) ? end : valStart;
}
pos = valEnd + 1;
if (nameEnd <= nameStart) {
log.warn("Parameters: Invalid chunk ignored.");
continue;
// invalid chunk - it's better to ignore
}
tmpName.setBytes(bytes, nameStart, nameEnd - nameStart);
tmpValue.setBytes(bytes, valStart, valEnd - valStart);
try {
addParam(urlDecode(tmpName, enc), urlDecode(tmpValue, enc));
} catch (IOException e) {
// Exception during character decoding: skip parameter
log.warn("Parameters: Character decoding failed. "
+ "Parameter skipped.", e);
}
tmpName.recycle();
tmpValue.recycle();
} while (pos < end);
}