Package com.davfx.ninio.http

Examples of com.davfx.ninio.http.HttpClient


  public AllAvailableScriptRunner() throws IOException {
    queue = new Queue();
    executorScriptRunner = new ExecutorScriptRunner();
   
    http = new HttpClient(queue, null);
   
    telnet = new WaitingTelnetClientCache(queue);
   
    ssh = new WaitingTelnetClientCache(queue);
    ssh.override(new SshTelnetConnectorFactory());
View Full Code Here


  public AutoCloseable send(SimpleHttpClientHandler handler) {
    return finish().send(handler);
  }
 
  public Finished finish() {
    final HttpClient onClient;
    final boolean shouldCloseClient;
    final Queue q;
    final boolean shouldCloseQueue;
    if (client == null) {
      if (queue == null) {
        try {
          q = new Queue();
        } catch (IOException e) {
          LOGGER.error("Queue could not be created", e);
          return null;
        }
        shouldCloseQueue = true;
      } else {
        q = queue;
        shouldCloseQueue = false;
      }
      onClient = new HttpClient(q, trust);
      shouldCloseClient = true;
    } else {
      onClient = client;
      shouldCloseClient = false;
      q = null;
      shouldCloseQueue = false;
    }
   
    return new Finished() {
      @Override
      public void close() {
        if (shouldCloseQueue) {
          q.close();
        }
        if (shouldCloseClient) {
          onClient.close();
        }
      }
     
      @Override
      public Finished send(final SimpleHttpClientHandler handler) {
        final Address a;
        if (host != null) {
          if (port < 0) {
            a = new Address(host, secure ? Http.DEFAULT_SECURE_PORT : Http.DEFAULT_PORT);
          } else {
            a = new Address(host, port);
          }
        } else {
          a = address;
        }
       
        if (post != null) {
          method = HttpRequest.Method.POST;
        }
        HttpRequest request = new HttpRequest(a, secure, method, path);
        if (post != null) {
          request.getHeaders().put(Http.CONTENT_LENGTH, String.valueOf(post.remaining()));
        }
        onClient.send(request, new HttpClientHandler() {
          private HttpResponse response = null;
          private InMemoryPost body = null;
         
          @Override
          public void ready(ByteBufferHandler write) {
View Full Code Here

  public AutoCloseable send(SimpleHttpClientHandler handler) {
    return finish().send(handler);
  }
 
  public Finished finish() {
    HttpClient onClient;
    boolean shouldCloseClient;
    Queue q;
    boolean shouldCloseQueue;
    if (client == null) {
      if (queue == null) {
        try {
          q = new Queue();
        } catch (IOException e) {
          LOGGER.error("Queue could not be created", e);
          return null;
        }
        shouldCloseQueue = true;
      } else {
        q = queue;
        shouldCloseQueue = false;
      }
      onClient = new HttpClient(q, trust);
      shouldCloseClient = true;
    } else {
      onClient = client;
      shouldCloseClient = false;
      q = null;
      shouldCloseQueue = false;
    }
   
    return new Finished() {
      @Override
      public void close() {
        if (shouldCloseQueue) {
          q.close();
        }
        if (shouldCloseClient) {
          onClient.close();
        }
      }
     
      @Override
      public Finished send(final SimpleHttpClientHandler handler) {
        Address a = address;
        if (host != null) {
          if (port < 0) {
            a = new Address(host, secure ? Http.DEFAULT_SECURE_PORT : Http.DEFAULT_PORT);
          } else {
            a = new Address(host, port);
          }
        }
       
        if (post != null) {
          method = HttpRequest.Method.POST;
        }
        HttpRequest request = new HttpRequest(a, secure, method, path);
        if (post != null) {
          request.getHeaders().put(Http.CONTENT_LENGTH, String.valueOf(post.remaining()));
        }
        onClient.send(request, new HttpClientHandler() {
          private HttpResponse response = null;
          private InMemoryPost body = null;
         
          @Override
          public void ready(ByteBufferHandler write) {
View Full Code Here

  private final RegisteredFunctionsScriptRunner runner;

  public AllAvailableScriptRunner() throws IOException {
    queue = new Queue();
    singleExecutorScriptRunner = new SingleExecutorScriptRunner();
    http = new HttpClient(queue, null);
    telnet = new WaitingTelnetClientCache(queue);
    snmp = new SnmpClientCache(queue);
    ping = new PingClientCache(queue);

    runner = new PingAvailable(ping).register(
View Full Code Here

TOP

Related Classes of com.davfx.ninio.http.HttpClient

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.