use of com.koushikdutta.ion.HeadersResponse in project ion by koush.
the class HeadersTests method testHeaders.
public void testHeaders() throws Exception {
gotHeaders = false;
AsyncHttpServer httpServer = new AsyncHttpServer();
try {
httpServer.get("/", new HttpServerRequestCallback() {
@Override
public void onRequest(AsyncHttpServerRequest request, AsyncHttpServerResponse response) {
response.send("hello");
}
});
httpServer.listen(Ion.getDefault(getContext()).getServer(), 5555);
Ion.with(getContext()).load("http://localhost:5555/").onHeaders(new HeadersCallback() {
@Override
public void onHeaders(HeadersResponse headers) {
assertEquals(headers.code(), 200);
gotHeaders = true;
}
}).asString().get();
assertTrue(gotHeaders);
} finally {
httpServer.stop();
Ion.getDefault(getContext()).getServer().stop();
}
}
Aggregations