Example usage for org.apache.http.client.methods CloseableHttpResponse getLastHeader

List of usage examples for org.apache.http.client.methods CloseableHttpResponse getLastHeader

Introduction

In this page you can find the example usage for org.apache.http.client.methods CloseableHttpResponse getLastHeader.

Prototype

Header getLastHeader(String str);

Source Link

Usage

From source file:org.springframework.cloud.netflix.zuul.filters.route.SimpleHostRoutingFilterTests.java

@Test
public void redirectTest() throws IOException {
    setupContext();//from w  w w  .  java  2  s . c o m
    InputStreamEntity inputStreamEntity = new InputStreamEntity(new ByteArrayInputStream(new byte[] {}));
    HttpRequest httpRequest = getFilter().buildHttpRequest("GET", "/app/redirect", inputStreamEntity,
            new LinkedMultiValueMap<>(), new LinkedMultiValueMap<>(), new MockHttpServletRequest());

    CloseableHttpResponse response = getFilter().newClient().execute(new HttpHost("localhost", this.port),
            httpRequest);
    assertEquals(302, response.getStatusLine().getStatusCode());
    String responseString = copyToString(response.getEntity().getContent(), Charset.forName("UTF-8"));
    assertTrue(response.getLastHeader("Location").getValue().contains("/app/get/5"));
}