Package com.davfx.ninio.http.util

Examples of com.davfx.ninio.http.util.SimpleHttpClient


        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));
View Full Code Here


        return e.getAsBoolean();
      }
      @Override
      public void call(JsonElement request, ScriptFunction.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 = getInteger(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));
View Full Code Here

TOP

Related Classes of com.davfx.ninio.http.util.SimpleHttpClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.