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


Java AsciiString.of方法代码示例

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


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

示例1: toArmeria

import io.netty.util.AsciiString; //导入方法依赖的package包/类
/**
 * Converts the specified Netty HTTP/2 into Armeria HTTP/2 headers.
 */
public static HttpHeaders toArmeria(Http2Headers headers) {
    final HttpHeaders converted = new DefaultHttpHeaders(false, headers.size());
    StringJoiner cookieJoiner = null;
    for (Entry<CharSequence, CharSequence> e : headers) {
        final AsciiString name = AsciiString.of(e.getKey());
        final CharSequence value = e.getValue();

        // Cookies must be concatenated into a single octet string.
        // https://tools.ietf.org/html/rfc7540#section-8.1.2.5
        if (name.equals(HttpHeaderNames.COOKIE)) {
            if (cookieJoiner == null) {
                cookieJoiner = new StringJoiner(COOKIE_SEPARATOR);
            }
            COOKIE_SPLITTER.split(value).forEach(cookieJoiner::add);
        } else {
            converted.add(name, value.toString());
        }
    }

    if (cookieJoiner != null && cookieJoiner.length() != 0) {
        converted.add(HttpHeaderNames.COOKIE, cookieJoiner.toString());
    }

    return converted;
}
 
开发者ID:line,项目名称:armeria,代码行数:29,代码来源:ArmeriaHttpUtil.java

示例2: leLengthString

import io.netty.util.AsciiString; //导入方法依赖的package包/类
@Test
public void leLengthString() throws Exception {
    ByteBuf dest = Unpooled.buffer();
    AsciiString string = AsciiString.of("test");
    McpeUtil.writeLELengthAsciiString(dest, string);
    assertEquals(string, McpeUtil.readLELengthAsciiString(dest));
    dest.release();
}
 
开发者ID:voxelwind,项目名称:voxelwind,代码行数:9,代码来源:McpeUtilTest.java

示例3: newAccessLogComponent

import io.netty.util.AsciiString; //导入方法依赖的package包/类
private static AccessLogComponent newAccessLogComponent(char token,
                                                        @Nullable String variable,
                                                        @Nullable Condition.Builder condBuilder) {
    final AccessLogType type = AccessLogType.find(token).orElseThrow(
            () -> new IllegalArgumentException("Unexpected token character: '" + token + '\''));
    if (type.isVariableRequired()) {
        checkArgument(variable != null,
                      "Token " + type.token() + " requires a variable.");
    }
    if (type.isConditionAvailable()) {
        if (condBuilder != null) {
            checkArgument(!condBuilder.isEmpty(),
                          "Token " + type.token() + " has an invalid condition.");
        }
    } else {
        checkArgument(condBuilder == null,
                      "Token " + type.token() + " does not support a condition.");
    }

    if (TextComponent.isSupported(type)) {
        return ofText(variable);
    }

    // Do not add quotes when parsing a user-provided custom format.
    final boolean addQuote = false;

    final Function<HttpHeaders, Boolean> condition = condBuilder != null ? condBuilder.build() : null;
    if (CommonComponent.isSupported(type)) {
        return new CommonComponent(type, addQuote, condition);
    }
    if (RequestHeaderComponent.isSupported(type)) {
        return new RequestHeaderComponent(AsciiString.of(variable), addQuote, condition);
    }
    if (AttributeComponent.isSupported(type)) {
        final Function<Object, String> stringifier;
        final String[] components = variable.split(":");
        if (components.length == 2) {
            stringifier = newStringifier(components[0], components[1]);
        } else {
            stringifier = Object::toString;
        }
        return new AttributeComponent(components[0], stringifier, addQuote, condition);
    }

    // Should not reach here.
    throw new Error("Unexpected access log type: " + type.name());
}
 
开发者ID:line,项目名称:armeria,代码行数:48,代码来源:AccessLogFormats.java


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