return e.getAsBoolean();
}
@Override
public void call(JsonElement request, final AsyncScriptFunction.Callback<JsonElement> callback) {
JsonObject r = request.getAsJsonObject();
SimpleHttpClient c = new SimpleHttpClient().on(client);
c.withMethod(HttpRequest.Method.valueOf(getString(r, "method", "GET").toUpperCase()));
String post = getString(r, "post", null);
if (post != null) {
c.post(ByteBuffer.wrap(post.getBytes(Http.UTF8_CHARSET)));
}
String path = getString(r, "path", null);
String host = getString(r, "host", "localhost");
Integer port = getInt(r, "port", null);
Boolean secure = getBoolean(r, "secure", null);
c.on(path).withHost(host);
if (port != null) {
c.withPort(port);
}
if (secure != null) {
c.secure(secure);
}
c.send(new SimpleHttpClientHandler() {
@Override
public void handle(int status, String reason, InMemoryPost body) {
JsonObject r = new JsonObject();
r.add("status", new JsonPrimitive(status));
r.add("reason", new JsonPrimitive(reason));