Examples of SimpleHttpClient


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

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

        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

Examples of nz.co.wetstone.http.SimpleHTTPClient

                System.out.println("DEBUG::JSON Request: " + json);
            }
            SimpleHTTPClient.URIParameterBuilder builder = new SimpleHTTPClient.URIParameterBuilder();
            builder.setHost(url);
            builder.setStringEntity(json);
            SimpleHTTPClient client = new SimpleHTTPClient();
            client.addHeader("Content-Type", "application/json");
            String response = client.grabPageHTML(SimpleHTTPClient.HTTP_POST, builder);
            if(debug) {
                System.out.println("DEBUG::JSON Response: " + response);
            }
            return createResult(response);
        } catch (IOException ex) {
View Full Code Here

Examples of nz.co.wetstone.http.SimpleHTTPClient

        setKrakedSize(JSONHelper.getLongSafe(j, "kraked_size"));
        setKrakedUrl(JSONHelper.getStringSafe(j, "kraked_url"));
        setOriginalSize(JSONHelper.getLongSafe(j, "original_size"));
        setSavedBytes(JSONHelper.getLongSafe(j, "saved_bytes"));
        setSuccess(JSONHelper.getBooleanSafe(j, "success"));
        SimpleHTTPClient client = new SimpleHTTPClient();
        try {
            setKrakedFile(client.grabRawStream(getKrakedUrl()));
        } catch (IllegalStateException ex) {
            Logger.getLogger(JKrakenResult.class.getName()).log(Level.SEVERE, "", ex);
        } catch (IOException ex) {
            Logger.getLogger(JKrakenResult.class.getName()).log(Level.SEVERE, "", ex);
        }
View Full Code Here

Examples of org.apache.catalina.startup.SimpleHttpClient

        w.setAsyncSupported(true);
        ctx.addServletMapping("/async", "async");

        tomcat.start();

        SimpleHttpClient client = new SimpleHttpClient() {
            @Override
            public boolean isResponseBodyOK() {
                return true;
            }
        };

        String request = "GET /async HTTP/1.1" + SimpleHttpClient.CRLF +
                "Host: a" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;

        client.setPort(getPort());
        client.setRequest(new String[] {request});

        client.connect();
        client.sendRequest();

        for (int i = 0; i < 10; i++) {
            System.out.println(client.readLine());
        }

        client.disconnect();

        // Wait for server thread to stop
        while (servlet.getThread().isAlive()) {
            Thread.sleep(250);
        }
View Full Code Here

Examples of org.apache.catalina.startup.SimpleHttpClient

        w.setAsyncSupported(true);
        ctx.addServletMapping("/async", "async");

        tomcat.start();

        SimpleHttpClient client = new SimpleHttpClient() {
            @Override
            public boolean isResponseBodyOK() {
                return true;
            }
        };

        String request = "GET /async HTTP/1.1" + SimpleHttpClient.CRLF +
                "Host: a" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;

        client.setPort(getPort());
        client.setRequest(new String[] {request});

        client.connect();
        client.sendRequest();

        for (int i = 0; i < 10; i++) {
            System.out.println(client.readLine());
        }

        client.disconnect();

        // Wait for server thread to stop
        while (servlet.getThread().isAlive()) {
            Thread.sleep(250);
        }
View Full Code Here

Examples of org.apache.catalina.startup.SimpleHttpClient

        w.setAsyncSupported(true);
        ctx.addServletMapping("/async", "async");

        tomcat.start();

        SimpleHttpClient client = new SimpleHttpClient() {
            @Override
            public boolean isResponseBodyOK() {
                return true;
            }
        };

        String request = "GET /async HTTP/1.1" + SimpleHttpClient.CRLF +
                "Host: a" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;

        client.setPort(getPort());
        client.setRequest(new String[] {request});

        client.connect();
        client.sendRequest();

        for (int i = 0; i < 10; i++) {
            System.out.println(client.readLine());
        }

        client.disconnect();

        // Wait for server thread to stop
        int count = 0;
        while (servlet.getThread().isAlive() && count < 10) {
            Thread.sleep(250);
View Full Code Here

Examples of org.apache.catalina.startup.SimpleHttpClient

        w.setAsyncSupported(true);
        ctx.addServletMapping("/async", "async");

        tomcat.start();

        SimpleHttpClient client = new SimpleHttpClient() {
            @Override
            public boolean isResponseBodyOK() {
                return true;
            }
        };

        String request = "GET /async HTTP/1.1" + SimpleHttpClient.CRLF +
                "Host: a" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;

        client.setPort(getPort());
        client.setRequest(new String[] {request});

        client.connect();
        client.sendRequest();

        for (int i = 0; i < 10; i++) {
            String line = client.readLine();
            if (line != null && line.length() > 20)
            System.err.println(line.subSequence(0, 20) + "...");
        }

        client.disconnect();

        // Wait for server thread to stop
        int count = 0;
        while (servlet.getThread().isAlive() && count < 20) {
            Thread.sleep(250);
View Full Code Here

Examples of org.apache.catalina.startup.SimpleHttpClient

        w.setAsyncSupported(true);
        ctx.addServletMapping("/async", "async");

        tomcat.start();

        SimpleHttpClient client = new SimpleHttpClient() {
            @Override
            public boolean isResponseBodyOK() {
                return true;
            }
        };

        String request = "GET /async HTTP/1.1" + SimpleHttpClient.CRLF +
                "Host: a" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;

        client.setPort(getPort());
        client.setRequest(new String[] {request});

        client.connect();
        client.sendRequest();

        for (int i = 0; i < 10; i++) {
            String line = client.readLine();
            if (line != null && line.length() > 20) {
                log.info(line.subSequence(0, 20) + "...");
            }
        }

        client.disconnect();

        // Wait for server thread to stop
        Thread t = servlet.getThread();
        long startTime = System.nanoTime();
        t.join(5000);
View Full Code Here

Examples of org.apache.catalina.startup.SimpleHttpClient

        w.setAsyncSupported(true);
        ctx.addServletMapping("/async", "async");

        tomcat.start();

        SimpleHttpClient client = new SimpleHttpClient() {
            @Override
            public boolean isResponseBodyOK() {
                return true;
            }
        };

        String request = "GET /async HTTP/1.1" + SimpleHttpClient.CRLF +
                "Host: a" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF;

        client.setPort(getPort());
        client.setRequest(new String[] {request});

        client.connect();
        client.sendRequest();

        for (int i = 0; i < 10; i++) {
            String line = client.readLine();
            if (line != null && line.length() > 20) {
                log.info(line.subSequence(0, 20) + "...");
            }
        }

        client.disconnect();

        // Wait for server thread to stop
        Thread t = servlet.getThread();
        long startTime = System.nanoTime();
        t.join(5000);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.