use of com.koushikdutta.async.http.AsyncHttpGet in project AndroidAsync by koush.
the class Issue59 method testIssue.
public void testIssue() throws Exception {
AsyncHttpServer httpServer = new AsyncHttpServer();
try {
httpServer.get("/", new HttpServerRequestCallback() {
@Override
public void onRequest(AsyncHttpServerRequest request, final AsyncHttpServerResponse response) {
// setting this to empty is a hacky way of telling the framework not to use
// transfer-encoding. It will get removed.
response.getHeaders().set("Transfer-Encoding", "");
response.code(200);
Util.writeAll(response, "foobarbeepboop".getBytes(), new CompletedCallback() {
@Override
public void onCompleted(Exception ex) {
response.end();
}
});
}
});
httpServer.listen(5959);
AsyncHttpGet get = new AsyncHttpGet("http://localhost:5959/");
get.setLogging("issue59", Log.VERBOSE);
get.getHeaders().removeAll("Connection");
get.getHeaders().removeAll("Accept-Encoding");
assertEquals("foobarbeepboop", AsyncHttpClient.getDefaultInstance().executeString(get, null).get(1000, TimeUnit.MILLISECONDS));
} finally {
httpServer.stop();
AsyncServer.getDefault().stop();
}
}
use of com.koushikdutta.async.http.AsyncHttpGet in project AndroidAsync by koush.
the class RedirectTests method testRelativeRedirect.
public void testRelativeRedirect() throws Exception {
String ret = AsyncHttpClient.getDefaultInstance().executeString(new AsyncHttpGet("http://localhost:6003/foo/bar"), null).get();
assertEquals(ret, "SUCCESS!");
ret = AsyncHttpClient.getDefaultInstance().executeString(new AsyncHttpGet("http://localhost:6003/foo"), null).get();
assertEquals(ret, "BORAT!");
ret = AsyncHttpClient.getDefaultInstance().executeString(new AsyncHttpGet("http://localhost:6003/foo/poo"), null).get();
assertEquals(ret, "SWEET!");
}
Aggregations