use of org.pixmob.httpclient.HttpResponseHandler 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"));
}
Aggregations