use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project neo4j by neo4j.
the class RetrieveRelationshipsFromNodeIT method shouldParameteriseUrisInRelationshipRepresentationWithHostHeaderValue.
@Test
public void shouldParameteriseUrisInRelationshipRepresentationWithHostHeaderValue() throws Exception {
HttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet("http://localhost:7474/db/data/relationship/" + likes);
httpget.setHeader("Accept", "application/json");
httpget.setHeader("Host", "dummy.neo4j.org");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
String entityBody = IOUtils.toString(entity.getContent(), StandardCharsets.UTF_8);
System.out.println(entityBody);
assertThat(entityBody, containsString("http://dummy.neo4j.org/db/data/relationship/" + likes));
assertThat(entityBody, not(containsString("localhost:7474")));
} finally {
httpclient.getConnectionManager().shutdown();
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project neo4j by neo4j.
the class DisableWADLIT method should404OnAnyUriEndinginWADL.
@Test
public void should404OnAnyUriEndinginWADL() throws Exception {
URI nodeUri = new URI("http://localhost:7474/db/data/application.wadl");
HttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(nodeUri);
httpget.setHeader("Accept", "*/*");
HttpResponse response = httpclient.execute(httpget);
assertEquals(404, response.getStatusLine().getStatusCode());
} finally {
httpclient.getConnectionManager().shutdown();
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project neo4j by neo4j.
the class ConfigureBaseUriIT method shouldForwardHttpAndFirstHost.
@Test
public void shouldForwardHttpAndFirstHost() throws Exception {
URI rootUri = functionalTestHelper.baseUri();
HttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(rootUri);
httpget.setHeader("Accept", "application/json");
httpget.setHeader("X-Forwarded-Host", "foobar.com, bazbar.com");
httpget.setHeader("X-Forwarded-Proto", "http");
HttpResponse response = httpclient.execute(httpget);
String length = response.getHeaders("CONTENT-LENGTH")[0].getValue();
byte[] data = new byte[Integer.valueOf(length)];
response.getEntity().getContent().read(data);
String responseEntityBody = new String(data);
assertTrue(responseEntityBody.contains("http://foobar.com"));
assertFalse(responseEntityBody.contains("http://localhost"));
} finally {
httpclient.getConnectionManager().shutdown();
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project neo4j by neo4j.
the class ConfigureBaseUriIT method shouldForwardHttpAndHost.
@Test
public void shouldForwardHttpAndHost() throws Exception {
URI rootUri = functionalTestHelper.baseUri();
HttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(rootUri);
httpget.setHeader("Accept", "application/json");
httpget.setHeader("X-Forwarded-Host", "foobar.com");
httpget.setHeader("X-Forwarded-Proto", "http");
HttpResponse response = httpclient.execute(httpget);
String length = response.getHeaders("CONTENT-LENGTH")[0].getValue();
byte[] data = new byte[Integer.valueOf(length)];
response.getEntity().getContent().read(data);
String responseEntityBody = new String(data);
assertTrue(responseEntityBody.contains("http://foobar.com"));
assertFalse(responseEntityBody.contains("http://localhost"));
} finally {
httpclient.getConnectionManager().shutdown();
}
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project neo4j by neo4j.
the class ConfigureBaseUriIT method shouldUseRequestUriWhenNoXForwardHeadersPresent.
@Test
public void shouldUseRequestUriWhenNoXForwardHeadersPresent() throws Exception {
URI rootUri = functionalTestHelper.baseUri();
HttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(rootUri);
httpget.setHeader("Accept", "application/json");
HttpResponse response = httpclient.execute(httpget);
String length = response.getHeaders("CONTENT-LENGTH")[0].getValue();
byte[] data = new byte[Integer.valueOf(length)];
response.getEntity().getContent().read(data);
String responseEntityBody = new String(data);
assertFalse(responseEntityBody.contains("https://foobar.com"));
assertFalse(responseEntityBody.contains(":0"));
assertTrue(responseEntityBody.contains("http://localhost"));
} finally {
httpclient.getConnectionManager().shutdown();
}
}
Aggregations