use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project android_frameworks_base by ParanoidAndroid.
the class AbstractProxyTest method testConnectViaProxy.
/**
* http://code.google.com/p/android/issues/detail?id=2690
*/
private void testConnectViaProxy(ProxyConfig proxyConfig) throws Exception {
MockResponse mockResponse = new MockResponse().setResponseCode(200).setBody("this response comes via a proxy");
server.enqueue(mockResponse);
server.play();
HttpClient httpProxyClient = newHttpClient();
HttpGet request = new HttpGet("http://android.com/foo");
proxyConfig.configure(server, httpProxyClient, request);
HttpResponse response = httpProxyClient.execute(request);
assertEquals("this response comes via a proxy", contentToString(response));
RecordedRequest get = server.takeRequest();
assertEquals("GET http://android.com/foo HTTP/1.1", get.getRequestLine());
assertContains(get.getHeaders(), "Host: android.com");
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project android_frameworks_base by ParanoidAndroid.
the class DefaultHttpClientTest method testServerClosesOutput.
private void testServerClosesOutput(SocketPolicy socketPolicy) throws Exception {
server.enqueue(new MockResponse().setBody("This connection won't pool properly").setSocketPolicy(socketPolicy));
server.enqueue(new MockResponse().setBody("This comes after a busted connection"));
server.play();
DefaultHttpClient client = new DefaultHttpClient();
HttpResponse a = client.execute(new HttpGet(server.getUrl("/a").toURI()));
assertEquals("This connection won't pool properly", contentToString(a));
assertEquals(0, server.takeRequest().getSequenceNumber());
HttpResponse b = client.execute(new HttpGet(server.getUrl("/b").toURI()));
assertEquals("This comes after a busted connection", contentToString(b));
// sequence number 0 means the HTTP socket connection was not reused
assertEquals(0, server.takeRequest().getSequenceNumber());
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse 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.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse 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.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse 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();
}
}
Aggregations