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 graphdb by neo4j-attic.
the class PingerTest method shouldRespondToHttpClientGet.
/**
* Test that the LocalTestServer actually works.
*
* @throws Exception
*/
@Test
public void shouldRespondToHttpClientGet() throws Exception {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(serverUrl + "/?id=storeId+v=kernelVersion");
System.out.println("HttpClient: http-get " + httpget.getURI());
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
int l;
byte[] tmp = new byte[2048];
while ((l = instream.read(tmp)) != -1) {
}
}
assertThat(response, notNullValue());
assertThat(response.getStatusLine().getStatusCode(), is(HttpStatus.SC_OK));
}
use of org.apache.http.HttpEntity in project android-demos by novoda.
the class JsonRequest method retrieveStream.
private InputStream retrieveStream(String url) {
DefaultHttpClient client = new DefaultHttpClient();
HttpGet getRequest = new HttpGet(url);
try {
HttpResponse getResponse = client.execute(getRequest);
final int statusCode = getResponse.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
Log.w(getClass().getSimpleName(), "An error occurred with this URL: " + url + " Http status code: " + statusCode);
return null;
}
HttpEntity getResponseEntity = getResponse.getEntity();
return getResponseEntity.getContent();
} catch (IOException e) {
getRequest.abort();
Log.e(TAG, "An error occurred with this URL: " + url, e);
}
return null;
}
use of org.apache.http.HttpEntity in project Android-Universal-Image-Loader by nostra13.
the class HttpClientImageDownloader method getStreamFromNetwork.
@Override
protected InputStream getStreamFromNetwork(String imageUri, Object extra) throws IOException {
HttpGet httpRequest = new HttpGet(imageUri);
HttpResponse response = httpClient.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
return bufHttpEntity.getContent();
}
Aggregations