Java Code Examples for io.netty.handler.codec.http.DefaultHttpHeaders#add()

The following examples show how to use io.netty.handler.codec.http.DefaultHttpHeaders#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HeadersBenchmark.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Setup(Level.Trial)
public void setup() {
    Map<String, String> headers = ExampleHeaders.EXAMPLES.get(exampleHeader);
    httpNames = new AsciiString[headers.size()];
    http2Names = new AsciiString[headers.size()];
    httpValues = new AsciiString[headers.size()];
    httpHeaders = new DefaultHttpHeaders(false);
    http2Headers = new DefaultHttp2Headers(false);
    int idx = 0;
    for (Map.Entry<String, String> header : headers.entrySet()) {
        String name = header.getKey();
        String httpName = toHttpName(name);
        String http2Name = toHttp2Name(name);
        String value = header.getValue();
        httpNames[idx] = new AsciiString(httpName);
        http2Names[idx] = new AsciiString(http2Name);
        httpValues[idx] = new AsciiString(value);
        httpHeaders.add(httpNames[idx], httpValues[idx]);
        http2Headers.add(http2Names[idx], httpValues[idx]);
        idx++;
    }
    slowHttp2Headers = new SlowHeaders(http2Headers);
    emptyHttpHeaders = new DefaultHttpHeaders(true);
    emptyHttp2Headers = new DefaultHttp2Headers(true);
    emptyHttpHeadersNoValidate = new DefaultHttpHeaders(false);
    emptyHttp2HeadersNoValidate = new DefaultHttp2Headers(false);
}
 
Example 2
Source File: HeadersBenchmark.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Benchmark
@BenchmarkMode(Mode.AverageTime)
public DefaultHttpHeaders httpPut() {
    DefaultHttpHeaders headers = new DefaultHttpHeaders(false);
    for (int i = 0; i < httpNames.length; i++) {
        headers.add(httpNames[i], httpValues[i]);
    }
    return headers;
}
 
Example 3
Source File: HttpRequestTemplate.java    From ribbon with Apache License 2.0 5 votes vote down vote up
private Builder(String name, HttpResourceGroup resourceGroup, Class<? extends T> classType) {
    this.name = name;
    this.resourceGroup = resourceGroup;
    this.classType = classType;
    headers = new DefaultHttpHeaders();
    headers.add(resourceGroup.getHeaders());
    parsedTemplates = new HashMap<String, ParsedTemplate>();
}
 
Example 4
Source File: StripUntrustedProxyHeadersHandlerTest.java    From zuul with Apache License 2.0 5 votes vote down vote up
@Before
public void before() {
    when(channelHandlerContext.channel()).thenReturn(channel);

    DefaultAttributeMap attributeMap = new DefaultAttributeMap();
    attributeMap.attr(ATTR_SSL_INFO).set(sslHandshakeInfo);
    when(channel.attr(any())).thenAnswer(arg -> attributeMap.attr((AttributeKey) arg.getArguments()[0]));

    headers = new DefaultHttpHeaders();
    when(msg.headers()).thenReturn(headers);
    headers.add(HttpHeaderNames.HOST, "netflix.com");
}