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


Java HttpScheme类代码示例

本文整理汇总了Java中io.netty.handler.codec.http.HttpScheme的典型用法代码示例。如果您正苦于以下问题:Java HttpScheme类的具体用法?Java HttpScheme怎么用?Java HttpScheme使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpScheme类属于io.netty.handler.codec.http包,在下文中一共展示了HttpScheme类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHeadersForPushNotification

import io.netty.handler.codec.http.HttpScheme; //导入依赖的package包/类
protected Http2Headers getHeadersForPushNotification(final ApnsPushNotification pushNotification, final int streamId) {
    final Http2Headers headers = new DefaultHttp2Headers()
            .method(HttpMethod.POST.asciiName())
            .authority(this.authority)
            .path(APNS_PATH_PREFIX + pushNotification.getToken())
            .scheme(HttpScheme.HTTPS.name())
            .addInt(APNS_EXPIRATION_HEADER, pushNotification.getExpiration() == null ? 0 : (int) (pushNotification.getExpiration().getTime() / 1000));

    if (pushNotification.getCollapseId() != null) {
        headers.add(APNS_COLLAPSE_ID_HEADER, pushNotification.getCollapseId());
    }

    if (pushNotification.getPriority() != null) {
        headers.addInt(APNS_PRIORITY_HEADER, pushNotification.getPriority().getCode());
    }

    if (pushNotification.getTopic() != null) {
        headers.add(APNS_TOPIC_HEADER, pushNotification.getTopic());
    }

    return headers;
}
 
开发者ID:relayrides,项目名称:pushy,代码行数:23,代码来源:ApnsClientHandler.java

示例2: HTTP2Client

import io.netty.handler.codec.http.HttpScheme; //导入依赖的package包/类
public HTTP2Client(boolean ssl, String host, int port) throws Exception {

        try {

            final SslContext sslCtx;
            if (ssl) {
                SslProvider provider = OpenSsl.isAlpnSupported() ? SslProvider.OPENSSL : SslProvider.JDK;
                sslCtx = SslContextBuilder.forClient()
                        .sslProvider(provider)
                        .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
                        .trustManager(InsecureTrustManagerFactory.INSTANCE)
                        .applicationProtocolConfig(new ApplicationProtocolConfig(
                                Protocol.ALPN,
                                // NO_ADVERTISE is currently the only mode supported by both OpenSsl and JDK providers.
                                SelectorFailureBehavior.NO_ADVERTISE,
                                // ACCEPT is currently the only mode supported by both OpenSsl and JDK providers.
                                SelectedListenerFailureBehavior.ACCEPT,
                                ApplicationProtocolNames.HTTP_2,
                                ApplicationProtocolNames.HTTP_1_1))
                        .build();
            } else {
                sslCtx = null;
            }
            workerGroup = new NioEventLoopGroup();
            HTTP2ClientInitializer initializer = new HTTP2ClientInitializer(sslCtx, Integer.MAX_VALUE);


            // Configure the client.
            Bootstrap b = new Bootstrap();
            b.group(workerGroup);
            b.channel(NioSocketChannel.class);
            b.option(ChannelOption.SO_KEEPALIVE, true);
            b.remoteAddress(host, port);
            b.handler(initializer);

            // Start the client.
            channel = b.connect().syncUninterruptibly().channel();
            log.info("Connected to [" + host + ':' + port + ']');

            // Wait for the HTTP/2 upgrade to occur.
            HTTP2SettingsHandler http2SettingsHandler = initializer.settingsHandler();
            http2SettingsHandler.awaitSettings(TestUtil.HTTP2_RESPONSE_TIME_OUT, TestUtil.HTTP2_RESPONSE_TIME_UNIT);
            responseHandler = initializer.responseHandler();
            scheme = ssl ? HttpScheme.HTTPS : HttpScheme.HTTP;
            hostName = new AsciiString(host + ':' + port);


        } catch (Exception ex) {
            log.error("Error while initializing http2 client " + ex);
            this.close();
        }

    }
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:54,代码来源:HTTP2Client.java


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