use of org.apache.http.HttpEntity in project neo4j by neo4j.
the class RetrieveNodeIT method shouldParameteriseUrisInNodeRepresentationWithHostHeaderValue.
@Test
public void shouldParameteriseUrisInNodeRepresentationWithHostHeaderValue() throws Exception {
HttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(nodeUri);
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);
assertThat(entityBody, containsString("http://dummy.neo4j.org/db/data/node/"));
} finally {
httpclient.getConnectionManager().shutdown();
}
}
use of org.apache.http.HttpEntity in project neo4j by neo4j.
the class RetrieveNodeIT method shouldParameteriseUrisInNodeRepresentationWithoutHostHeaderUsingRequestUri.
@Test
public void shouldParameteriseUrisInNodeRepresentationWithoutHostHeaderUsingRequestUri() throws Exception {
HttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(nodeUri);
httpget.setHeader("Accept", "application/json");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
String entityBody = IOUtils.toString(entity.getContent(), StandardCharsets.UTF_8);
assertThat(entityBody, containsString(nodeUri.toString()));
} finally {
httpclient.getConnectionManager().shutdown();
}
}
use of org.apache.http.HttpEntity in project neo4j by neo4j.
the class RetrieveRelationshipsFromNodeIT method shouldParameteriseUrisInRelationshipRepresentationWithoutHostHeaderUsingRequestUri.
@Test
public void shouldParameteriseUrisInRelationshipRepresentationWithoutHostHeaderUsingRequestUri() throws Exception {
HttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet("http://localhost:7474/db/data/relationship/" + likes);
httpget.setHeader("Accept", "application/json");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
String entityBody = IOUtils.toString(entity.getContent(), StandardCharsets.UTF_8);
assertThat(entityBody, containsString("http://localhost:7474/db/data/relationship/" + likes));
} finally {
httpclient.getConnectionManager().shutdown();
}
}
use of org.apache.http.HttpEntity 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.apache.http.HttpEntity in project pinpoint by naver.
the class DefaultClientExchangeHandlerImplStartMethodInterceptor method recordEntity.
protected void recordEntity(HttpMessage httpMessage, SpanEventRecorder recorder) {
if (httpMessage instanceof HttpEntityEnclosingRequest) {
final HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest) httpMessage;
try {
final HttpEntity entity = entityRequest.getEntity();
if (entity != null && entity.isRepeatable() && entity.getContentLength() > 0) {
if (entitySampler.isSampling()) {
final String entityString = entityUtilsToString(entity, "UTF8", 1024);
recorder.recordAttribute(AnnotationKey.HTTP_PARAM_ENTITY, entityString);
}
}
} catch (Exception e) {
logger.debug("HttpEntityEnclosingRequest entity record fail. Caused:{}", e.getMessage(), e);
}
}
}
Aggregations