Example usage for io.netty.handler.codec.http HttpHeaders EMPTY_HEADERS

List of usage examples for io.netty.handler.codec.http HttpHeaders EMPTY_HEADERS

Introduction

In this page you can find the example usage for io.netty.handler.codec.http HttpHeaders EMPTY_HEADERS.

Prototype

HttpHeaders EMPTY_HEADERS

To view the source code for io.netty.handler.codec.http HttpHeaders EMPTY_HEADERS.

Click Source Link

Usage

From source file:com.netflix.ribbon.http.HttpResourceGroup.java

License:Apache License

protected HttpResourceGroup(String groupName) {
    super(groupName, ClientOptions.create(), ClientConfigFactory.DEFAULT, RibbonTransportFactory.DEFAULT);
    client = transportFactory.newHttpClient(getClientConfig());
    headers = HttpHeaders.EMPTY_HEADERS;
}

From source file:org.apache.dubbo.qos.command.decoder.HttpCommandDecoderTest.java

License:Apache License

@Test
public void decodePost() throws Exception {
    FullHttpRequest request = mock(FullHttpRequest.class);
    when(request.getUri()).thenReturn("localhost:80/test");
    when(request.getMethod()).thenReturn(HttpMethod.POST);
    when(request.headers()).thenReturn(HttpHeaders.EMPTY_HEADERS);
    ByteBuf buf = Unpooled.copiedBuffer("a=b&c=d", StandardCharsets.UTF_8);
    when(request.content()).thenReturn(buf);
    CommandContext context = HttpCommandDecoder.decode(request);
    assertThat(context.getCommandName(), equalTo("test"));
    assertThat(context.isHttp(), is(true));
    assertThat(context.getArgs(), arrayContaining("b", "d"));
}

From source file:org.apache.tinkerpop.gremlin.driver.simple.WebSocketClient.java

License:Apache License

public WebSocketClient(final URI uri) {
    super("ws-client-%d");
    final Bootstrap b = new Bootstrap().group(group);
    b.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);

    final String protocol = uri.getScheme();
    if (!"ws".equals(protocol))
        throw new IllegalArgumentException("Unsupported protocol: " + protocol);

    try {/*from ww  w. j  a va 2s  .c om*/
        final WebSocketClientHandler wsHandler = new WebSocketClientHandler(WebSocketClientHandshakerFactory
                .newHandshaker(uri, WebSocketVersion.V13, null, false, HttpHeaders.EMPTY_HEADERS, 65536));
        final MessageSerializer serializer = new GryoMessageSerializerV1d0();
        b.channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
            @Override
            protected void initChannel(final SocketChannel ch) {
                final ChannelPipeline p = ch.pipeline();
                p.addLast(new HttpClientCodec(), new HttpObjectAggregator(65536), wsHandler,
                        new WebSocketGremlinRequestEncoder(true, serializer),
                        new WebSocketGremlinResponseDecoder(serializer), callbackResponseHandler);
            }
        });

        channel = b.connect(uri.getHost(), uri.getPort()).sync().channel();
        wsHandler.handshakeFuture().get(10000, TimeUnit.MILLISECONDS);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}

From source file:org.asynchttpclient.netty.NettyResponse.java

License:Open Source License

@Override
public final HttpHeaders getHeaders() {
    return headers != null ? headers.getHeaders() : HttpHeaders.EMPTY_HEADERS;
}

From source file:org.asynchttpclient.request.body.multipart.MultipartBodyTest.java

License:Open Source License

private MultipartBody buildMultipart() throws URISyntaxException {
    List<Part> parts = new ArrayList<>();
    parts.add(new FilePart("filePart", getTestfile()));
    parts.add(new ByteArrayPart("baPart", "testMultiPart".getBytes(UTF_8), "application/test", UTF_8,
            "fileName"));
    parts.add(new StringPart("stringPart", "testString"));
    return MultipartUtils.newMultipartBody(parts, HttpHeaders.EMPTY_HEADERS);
}