Asynchronous HTTP Client for Java

后端 未结 13 1506
梦谈多话
梦谈多话 2020-12-01 05:01

As a relative newbie in the Java world, I am finding many things frustratingly obtuse to accomplish that are relatively trivial in many other frameworks. A primary example i

相关标签:
13条回答
  • 2020-12-01 05:25

    httpunit and htmlunit are 2 customizable and configurable Java http clients able to anything a browser such as simulate firefox, headless browsing, scheduled software clients and agents.

    0 讨论(0)
  • 2020-12-01 05:26

    there are libraries and frameworks written on top of NIO/Netty - RxNetty and Vertx which can be helpful to write asynchronous HTTP client

    Below is an example code using vertx

    public class Client extends AbstractVerticle {
    
      @Override
      public void start() throws Exception {
        //lambda callback would be called when the response comes back
        vertx.createHttpClient().getNow(8080, "localhost", "/", resp -> {
          System.out.println("Got response " + resp.statusCode());
          resp.bodyHandler(body -> {
            System.out.println("Got data " + body.toString("ISO-8859-1"));
          });
        });
       //this code statement will execute before response comes back
       System.out.println("I am not blocked");
      }
    }
    

    you can find the full blown example code from here

    0 讨论(0)
  • 2020-12-01 05:27

    Looks like you want (a part of) NIO -- there's a good tutorial here, the asynchronous networking part starts at p. 30 and there are many useful links at the end.

    0 讨论(0)
  • 2020-12-01 05:28

    Asyncweb provides an asynchronous http client along with its http server. Available for download from the following location:

    https://svn.apache.org/repos/asf/mina/asyncweb/trunk

    0 讨论(0)
  • 2020-12-01 05:31

    I just stumbled upon the asynchronous HTTP client implemented within Geronimo. You might also want to take a look it, at http://svn.apache.org/viewvc/geronimo/sandbox/AsyncHttpClient/ - Caveat: the latest commit seems over a year old.

    Another project building an asynchronous HTTP client is xsocket: xsocket.sourceforge.net

    0 讨论(0)
  • 2020-12-01 05:33

    Take also a look into http://www.javaworld.com/javaworld/jw-03-2008/jw-03-asynchhttp.html This article discusses async HTTP based on a HttpClient named xLightweb

    0 讨论(0)
提交回复
热议问题