io.reactivex.netty.protocol.http.client.HttpRequestHeaders Java Examples

The following examples show how to use io.reactivex.netty.protocol.http.client.HttpRequestHeaders. 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: HttpUtils.java    From azure-cosmosdb-java with MIT License 5 votes vote down vote up
public static Map<String, String> asMap(HttpRequestHeaders headers) {
    HashMap<String, String> map = new HashMap<>();
    if (headers == null) {
        return map;
    }
    for (Entry<String, String> entry : headers.entries()) {
        map.put(entry.getKey(), entry.getValue());
    }
    return map;
}
 
Example #2
Source File: MesosClientTest.java    From mesos-rxjava with Apache License 2.0 5 votes vote down vote up
@NotNull
private static Map<String, String> headersToMap(@NotNull final HttpRequestHeaders headers) {
    final HashMap<String, String> map = Maps.newHashMap();
    for (Map.Entry<String, String> entry : headers.entries()) {
        map.put(entry.getKey(), entry.getValue());
    }
    return Collections.unmodifiableMap(map);
}
 
Example #3
Source File: TemplateBuilderTest.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@Test
  public void testHttpHeaders() {
      HttpResourceGroup group = Ribbon.createHttpResourceGroupBuilder("test")
          .withHeader("header1", "group").build();
      
      HttpRequestTemplate<String> template = group.newTemplateBuilder("testHttpHeaders", String.class)
          .withUriTemplate("/foo/bar")
          .withMethod("GET")
          .withHeader("header2", "template")
          .withHeader("header1", "template").build();
      
      HttpRequestBuilder<String> requestBuilder = template.requestBuilder();
      requestBuilder.withHeader("header3", "builder").withHeader("header1", "builder");
HttpClientRequest<ByteBuf> request = requestBuilder.createClientRequest();
      HttpRequestHeaders headers = request.getHeaders();
      List<String> header1 = headers.getAll("header1");
      assertEquals(3, header1.size());
      assertEquals("group", header1.get(0));
      assertEquals("template", header1.get(1));
      assertEquals("builder", header1.get(2));
      List<String> header2 = headers.getAll("header2");
      assertEquals(1, header2.size());
      assertEquals("template", header2.get(0));
      List<String> header3 = headers.getAll("header3");
      assertEquals(1, header3.size());
      assertEquals("builder", header3.get(0));
  }
 
Example #4
Source File: HttpTransportClient.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
private void beforeRequest(String activityId, String uri, ResourceType resourceType, HttpRequestHeaders requestHeaders) {
    // TODO: perf counters
    // https://msdata.visualstudio.com/CosmosDB/_workitems/edit/258624
}
 
Example #5
Source File: HttpTransportClient.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
private static void addHeader(HttpRequestHeaders requestHeaders, String headerName, RxDocumentServiceRequest request) {
    String headerValue = request.getHeaders().get(headerName);
    if (!Strings.isNullOrEmpty(headerValue)) {
        requestHeaders.add(headerName, headerValue);
    }
}
 
Example #6
Source File: HttpTransportClient.java    From azure-cosmosdb-java with MIT License 4 votes vote down vote up
private static void addHeader(HttpRequestHeaders requestHeaders, String headerName, String headerValue) {
    if (!Strings.isNullOrEmpty(headerValue)) {
        requestHeaders.add(headerName, headerValue);
    }
}