use of org.pixmob.httpclient.HttpResponse in project httpclient by pixmob.
the class PostFormTask method doRun.
@Override
protected void doRun() throws Exception {
final HttpClient hc = createClient();
hc.post("http://groovyconsole.appspot.com/executor.groovy").param("script", "printf 'Hello Android!'").to(new HttpResponseHandler() {
@Override
public void onResponse(HttpResponse response) throws Exception {
final StringBuilder rawJson = new StringBuilder(64);
response.read(rawJson);
final JSONObject json = new JSONObject(rawJson.toString());
assertEquals("Hello Android!", json.getString("outputText"));
}
}).execute();
final HttpResponse resp = hc.post("http://groovyconsole.appspot.com/executor.groovy").param("script", "printf 'Hello Android! (inline)'").execute();
final StringBuilder rawJson = new StringBuilder(64);
resp.read(rawJson);
final JSONObject json = new JSONObject(rawJson.toString());
assertEquals("Hello Android! (inline)", json.getString("outputText"));
}
use of org.pixmob.httpclient.HttpResponse in project httpclient by pixmob.
the class RedirectTask method doRun.
@Override
protected void doRun() throws Exception {
final HttpClient hc = createClient();
final HttpResponse response = hc.get("http://google.com").expect(HttpURLConnection.HTTP_MOVED_PERM).execute();
assertEquals("text/html", response.getContentType());
assertEquals("UTF-8", response.getContentCharset());
}
Aggregations