本文整理匯總了Java中io.undertow.util.HttpString.tryFromString方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpString.tryFromString方法的具體用法?Java HttpString.tryFromString怎麽用?Java HttpString.tryFromString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.undertow.util.HttpString
的用法示例。
在下文中一共展示了HttpString.tryFromString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: MethodPredicate
import io.undertow.util.HttpString; //導入方法依賴的package包/類
MethodPredicate(String[] methods) {
HttpString[] values = new HttpString[methods.length];
for(int i = 0; i < methods.length; ++i) {
values[i] = HttpString.tryFromString(methods[i]);
}
this.methods = values;
}
示例2: build
import io.undertow.util.HttpString; //導入方法依賴的package包/類
@Override
public ExchangeAttribute build(final String token) {
if (token.startsWith("%{o,") && token.endsWith("}")) {
final HttpString headerName = HttpString.tryFromString(token.substring(4, token.length() - 1));
return new ResponseHeaderAttribute(headerName);
}
return null;
}
示例3: build
import io.undertow.util.HttpString; //導入方法依賴的package包/類
@Override
public ExchangeAttribute build(final String token) {
if (token.startsWith("%{i,") && token.endsWith("}")) {
final HttpString headerName = HttpString.tryFromString(token.substring(4, token.length() - 1));
return new RequestHeaderAttribute(headerName);
}
return null;
}
示例4: handle
import io.undertow.util.HttpString; //導入方法依賴的package包/類
public int handle(ByteBuffer buf) throws IOException {
while (buf.hasRemaining()) {
final byte b = buf.get();
if (state == STATE_TRAILER_NAME) {
if (b == '\r') {
if (builder.length() == 0) {
state = STATE_ENDING;
} else {
throw UndertowMessages.MESSAGES.couldNotDecodeTrailers();
}
} else if (b == '\n') {
if (builder.length() == 0) {
attachable.putAttachment(trailerAttachmentKey, headerMap);
return -1;
} else {
throw UndertowMessages.MESSAGES.couldNotDecodeTrailers();
}
} else if (b == ':') {
httpString = HttpString.tryFromString(builder.toString().trim());
state = STATE_TRAILER_VALUE;
builder.setLength(0);
} else {
builder.append((char) b);
}
} else if (state == STATE_TRAILER_VALUE) {
if (b == '\n') {
headerMap.put(httpString, builder.toString().trim());
httpString = null;
builder.setLength(0);
state = STATE_TRAILER_NAME;
} else if (b != '\r') {
builder.append((char) b);
}
} else if (state == STATE_ENDING) {
if (b == '\n') {
if (attachable != null) {
attachable.putAttachment(trailerAttachmentKey, headerMap);
}
return -1;
} else {
throw UndertowMessages.MESSAGES.couldNotDecodeTrailers();
}
} else {
throw new IllegalStateException();
}
}
return 0;
}