@Test public void headers_withReadOnlyHttpHeaders() { HttpHeaders httpHeaders = HttpHeaders.readOnlyHttpHeaders(new HttpHeaders()); DefaultRequest defaultRequest = new DefaultRequest(new DefaultUriBuilderFactory().builder(), HttpMethod.GET, httpHeaders, new HashMap<>(), BodyInserters.empty()); defaultRequest.headers().add(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE); assertThat(defaultRequest.headers().getFirst(HttpHeaders.ACCEPT)).isEqualTo(MediaType.APPLICATION_JSON_VALUE); }
public Builder(String scheme, String authority) { this(); if (scheme != null && authority != null) { uriBuilder = new DefaultUriBuilderFactory(scheme + "://" + authority).builder(); } else { uriBuilder = new DefaultUriBuilderFactory().builder(); } }
public Builder(MethodMetadata other) { this(); uriBuilder = new DefaultUriBuilderFactory(other.getRequestTemplate().getUriBuilder().build().toString()).builder(); variableIndexToName.putAll(other.getRequestTemplate().getVariableIndexToName()); headers.putAll(other.getRequestTemplate().getRequestHeaders().getHeaders()); headerIndexToName.putAll(other.getRequestTemplate().getRequestHeaders().getIndexToName()); httpMethod = other.getRequestTemplate().getHttpMethod(); targetMethod = other.getTargetMethod(); }
public DefaultRequest buildRequest(String headerName, String headerValue) { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.add(headerName, headerValue); return new DefaultRequest(new DefaultUriBuilderFactory().builder(), HttpMethod.GET, httpHeaders, new HashMap<>(), BodyInserters.empty()); }
private void testReconstructUriWithPath(String scheme, String path) { RibbonServer server = getRibbonServer(); IClientConfig config = mock(IClientConfig.class); when(config.get(CommonClientConfigKey.IsSecure)).thenReturn(true); when(clientFactory.getClientConfig(server.getServiceId())).thenReturn(config); RibbonLoadBalancerClient client = getRibbonLoadBalancerClient(server); ServiceInstance serviceInstance = client.choose(server.getServiceId()); URI expanded = new DefaultUriBuilderFactory() .expand(scheme + "://" + server.getServiceId() + path); URI reconstructed = client.reconstructURI(serviceInstance, expanded); assertThat(reconstructed).hasPath(path); }
public DefaultRequest buildRequest(String uri, Map<String, Object> variables) { UriBuilder uriBuilder = new DefaultUriBuilderFactory(uri).builder(); return new DefaultRequest(uriBuilder, HttpMethod.GET, new HttpHeaders(), variables, BodyInserters.empty()); }