use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project android_frameworks_base by ResurrectionRemix.
the class CookiesTest method testCookiesWithNonMatchingCase.
/**
* Test that cookies aren't case-sensitive with respect to hostname.
* http://b/3167208
*/
public void testCookiesWithNonMatchingCase() throws Exception {
// use a proxy so we can manipulate the origin server's host name
server = new MockWebServer();
server.enqueue(new MockResponse().addHeader("Set-Cookie: a=first; Domain=my.t-mobile.com").addHeader("Set-Cookie: b=second; Domain=.T-mobile.com").addHeader("Set-Cookie: c=third; Domain=.t-mobile.com").setBody("This response sets some cookies."));
server.enqueue(new MockResponse().setBody("This response gets those cookies back."));
server.play();
HttpClient client = new DefaultHttpClient();
client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, new HttpHost("localhost", server.getPort()));
HttpResponse getCookies = client.execute(new HttpGet("http://my.t-mobile.com/"));
getCookies.getEntity().consumeContent();
server.takeRequest();
HttpResponse sendCookies = client.execute(new HttpGet("http://my.t-mobile.com/"));
sendCookies.getEntity().consumeContent();
RecordedRequest sendCookiesRequest = server.takeRequest();
assertContains(sendCookiesRequest.getHeaders(), "Cookie: a=first; b=second; c=third");
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project android_frameworks_base by ResurrectionRemix.
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 ResurrectionRemix.
the class AbstractProxyTest method testExplicitNoProxyCancelsSystemProperty.
public void testExplicitNoProxyCancelsSystemProperty() throws Exception {
server.enqueue(new MockResponse().setBody("Via the origin server!"));
server.play();
System.setProperty("http.proxyHost", "proxy.foo");
System.setProperty("http.proxyPort", "8080");
HttpClient client = newHttpClient();
HttpGet request = new HttpGet(server.getUrl("/bar").toURI());
request.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, ConnRouteParams.NO_HOST);
HttpResponse response = client.execute(request);
assertEquals("Via the origin server!", contentToString(response));
RecordedRequest recordedRequest = server.takeRequest();
assertEquals("GET /bar HTTP/1.1", recordedRequest.getRequestLine());
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project tdi-studio-se by Talend.
the class Util method getRelationship.
private List<String> getRelationship(String tablename) throws ClientProtocolException, IOException {
LinkedList<String> result = new LinkedList<String>();
StringBuilder sb = new StringBuilder();
sb.append(this.baseurl);
sb.append("/api/now/table/");
sb.append("sys_db_object");
sb.append("?sysparm_exclude_reference_link=true");
sb.append("&sysparm_query=name=");
sb.append(tablename);
sb.append("&sysparm_fields=name,super_class");
HttpGet httpget = new HttpGet(sb.toString());
httpget.setHeader("Accept", "application/json");
HttpResponse response = this.client.execute(httpget);
Map<String, String> info = extractResponse4OneRowFromArray(response);
result.add(info.get("name"));
String superclass = info.get("super_class");
while (superclass != null && !superclass.isEmpty()) {
sb.setLength(0);
sb.append(this.baseurl);
sb.append("/api/now/table/");
sb.append("sys_db_object/");
sb.append(superclass);
sb.append("?sysparm_exclude_reference_link=true");
sb.append("&sysparm_fields=name,super_class");
httpget = new HttpGet(sb.toString());
httpget.setHeader("Accept", "application/json");
response = this.client.execute(httpget);
info = extractResponse4OneRowFromObject(response);
result.add(info.get("name"));
superclass = info.get("super_class");
}
Collections.reverse(result);
return result;
}
use of org.graylog.shaded.elasticsearch7.org.apache.http.HttpResponse in project tdi-studio-se by Talend.
the class paloconnection method sendToServer.
public HttpEntity sendToServer(List<NameValuePair> qparams, String strAPIUrl) throws paloexception {
try {
URI uri = URIUtils.createURI("http", strServer, Integer.valueOf(strPort), strAPIUrl, URLEncodedUtils.format(qparams, "UTF-8"), null);
HttpGet req = new HttpGet(uri);
// System.out.println(req.getURI());
// Send to Server
HttpResponse rsp = paloHttpClient.execute(paloTargetHost, req);
HttpEntity entity = rsp.getEntity();
if (rsp.getStatusLine().getStatusCode() != 200) {
// Error had been occured
// Close Connection and thend raise paloexception error
CSVReader csv = new CSVReader(entity.getContent(), ';', "UTF-8");
csv.setQuoteChar('"');
csv.readNext();
paloexception plX = new paloexception(csv.get(0), csv.get(1), csv.get(2));
csv.close();
entity.consumeContent();
// paloHttpClient.getConnectionManager().shutdown();
throw (plX);
} else {
return entity;
}
} catch (Exception e) {
// if(paloHttpClient!=null)paloHttpClient.getConnectionManager().shutdown();
throw new paloexception(e.getMessage());
}
}
Aggregations