Package com.ning.http.client

Examples of com.ning.http.client.AsyncHttpClient.preparePost()


                }
            });

            // Let Atmosphere suspend the connections.
            Thread.sleep(2500);
            c.preparePost(urlTarget + "/delay").addParameter("message", "foo").execute().get();
            c.preparePost(urlTarget + "/publishAndResume").addParameter("message", "bar").execute().get();

            try {
                latch.await(20, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
View Full Code Here


            });

            // Let Atmosphere suspend the connections.
            Thread.sleep(2500);
            c.preparePost(urlTarget + "/delay").addParameter("message", "foo").execute().get();
            c.preparePost(urlTarget + "/publishAndResume").addParameter("message", "bar").execute().get();

            try {
                latch.await(20, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                fail(e.getMessage());
View Full Code Here

                }
            });

            // Let Atmosphere suspend the connections.
            Thread.sleep(2500);
            c.preparePost(urlTarget + "/delay").addParameter("message", "foo").execute().get();
            c.preparePost(urlTarget + "/delayAndResume").addParameter("message", "bar").execute().get();

            try {
                latch.await(20, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
View Full Code Here

            });

            // Let Atmosphere suspend the connections.
            Thread.sleep(2500);
            c.preparePost(urlTarget + "/delay").addParameter("message", "foo").execute().get();
            c.preparePost(urlTarget + "/delayAndResume").addParameter("message", "bar").execute().get();

            try {
                latch.await(20, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
                fail(e.getMessage());
View Full Code Here

                    .setUsePreemptiveAuth(true)
                    .setScheme(Realm.AuthScheme.BASIC)
                    .build();
            // currently, not really async...
            Response response =
                    asyncHttpClient.preparePost(url)
                            .addHeader("Accept", "application/json")
                            .addHeader("Content-type", "application/json")
                            .setRealm(realm)
                            .setBody(jsonPayloadObject)
                            .execute().get();
View Full Code Here

             
              if (null == postContent) {
                asyncRequest = asyncHttpClient.prepareGet(request.endPointUrl.replace("$1", entityValue));
              }
              else {
                asyncRequest = asyncHttpClient.preparePost(request.endPointUrl.replace("$1", entityValue));             
              }//TESTED (by hand, "http://httpbin.org/post", "httpFields": { "Content": "test" }
             
              if (null != request.urlParams) {
                for (Map.Entry<String, String> keyValue: request.urlParams.entrySet()) {
                  asyncRequest = asyncRequest.addQueryParameter(keyValue.getKey(), keyValue.getValue().replace("$1", entityValue));
View Full Code Here

  @Test
  public void smallHttpPostBodyTest() throws ClientProtocolException, IOException, InterruptedException {
    final String body = "Roger Schildmeijer";
    final CountDownLatch latch = new CountDownLatch(1);
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    asyncHttpClient.preparePost("http://localhost:" + PORT + "/echo").setBody(body).
    execute(new AsyncCompletionHandler<Response>(){

      @Override
      public Response onCompleted(Response response) throws Exception{
        assertNotNull(response);
View Full Code Here

      body += "Roger Schildmeijer: " + i + "\n";
    }
    final String expectedBody = body;
    final CountDownLatch latch = new CountDownLatch(1);
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    asyncHttpClient.preparePost("http://localhost:" + PORT + "/echo").setBody(body).
    execute(new AsyncCompletionHandler<Response>(){

      @Override
      public Response onCompleted(Response response) throws Exception{
        assertNotNull(response);
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.