Examples of preparePost()


Examples of org.asynchttpclient.AsyncHttpClient.preparePost()

        File tmp = new File(System.getProperty("java.io.tmpdir") + File.separator + "zeroCopy.txt");
        tmp.deleteOnExit();
        final FileOutputStream stream = new FileOutputStream(tmp);
        try {

            Response resp = client.preparePost("http://127.0.0.1:" + port1 + "/").setBody(SIMPLE_TEXT_FILE).execute(new AsyncHandler<Response>() {
                public void onThrowable(Throwable t) {
                }

                public STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception {
                    bodyPart.writeTo(stream);
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePost()

    @Test(groups = { "standalone", "default_provider" })
    public void postWithQS() throws IOException, ExecutionException, TimeoutException, InterruptedException {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Future<Response> f = client.preparePost("http://127.0.0.1:" + port1 + "/?a=b").setBody("abc".getBytes()).execute();
            Response resp = f.get(3, TimeUnit.SECONDS);
            assertNotNull(resp);
            assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
        } finally {
            client.close();
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePost()

    @Test(groups = { "standalone", "default_provider" })
    public void postWithNulParamQS() throws IOException, ExecutionException, TimeoutException, InterruptedException {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Future<Response> f = client.preparePost("http://127.0.0.1:" + port1 + "/?a=").setBody("abc".getBytes()).execute(new AsyncCompletionHandlerBase() {

                @Override
                public STATE onStatusReceived(final HttpResponseStatus status) throws Exception {
                    if (!status.getUri().toUrl().equals("http://127.0.0.1:" + port1 + "/?a=")) {
                        throw new IOException(status.getUri().toUrl());
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePost()

    @Test(groups = { "standalone", "default_provider" })
    public void postWithNulParamsQS() throws IOException, ExecutionException, TimeoutException, InterruptedException {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Future<Response> f = client.preparePost("http://127.0.0.1:" + port1 + "/?a=b&c&d=e").setBody("abc".getBytes()).execute(new AsyncCompletionHandlerBase() {

                @Override
                public STATE onStatusReceived(final HttpResponseStatus status) throws Exception {
                    if (!status.getUri().toUrl().equals("http://127.0.0.1:" + port1 + "/?a=b&c&d=e")) {
                        throw new IOException("failed to parse the query properly");
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePost()

    @Test(groups = { "standalone", "default_provider" })
    public void postWithEmptyParamsQS() throws IOException, ExecutionException, TimeoutException, InterruptedException {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Future<Response> f = client.preparePost("http://127.0.0.1:" + port1 + "/?a=b&c=&d=e").setBody("abc".getBytes()).execute(new AsyncCompletionHandlerBase() {

                @Override
                public STATE onStatusReceived(final HttpResponseStatus status) throws Exception {
                    if (!status.getUri().toUrl().equals("http://127.0.0.1:" + port1 + "/?a=b&c=&d=e")) {
                        throw new IOException("failed to parse the query properly");
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePost()

    public void asyncConnectInvalidPortFuture() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            int dummyPort = findFreePort();
            try {
                Response response = client.preparePost(String.format("http://127.0.0.1:%d/", dummyPort)).execute(new AsyncCompletionHandlerAdapter() {
                    @Override
                    public void onThrowable(Throwable t) {
                        t.printStackTrace();
                    }
                }).get();
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePost()

        try {
            // pick a random unused local port
            int port = findFreePort();

            try {
                Response response = client.preparePost(String.format("http://127.0.0.1:%d/", port)).execute(new AsyncCompletionHandlerAdapter() {
                    @Override
                    public void onThrowable(Throwable t) {
                        t.printStackTrace();
                    }
                }).get();
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePost()

    @Test(groups = { "standalone", "default_provider", "async" })
    public void asyncResponseBodyTooLarge() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Response response = client.preparePost(getTargetUrl()).setBody("0123456789").execute(new AsyncCompletionHandlerAdapter() {

                @Override
                public void onThrowable(Throwable t) {
                    fail("Unexpected exception", t);
                }
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePost()

            sb.append("LockThread=true");

            final AtomicReference<CancellationException> ex = new AtomicReference<CancellationException>();
            ex.set(null);
            try {
                Future<Response> future = client.preparePost(getTargetUrl()).setHeaders(h).setBody(sb.toString()).execute(new AsyncCompletionHandlerAdapter() {

                    @Override
                    public void onThrowable(Throwable t) {
                        if (t instanceof CancellationException) {
                            ex.set((CancellationException) t);
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePost()

    @Test(groups = { "default_provider", "async" })
    public void mirrorByteTest() throws Exception {
        final AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Response response = client.preparePost(getTargetUrl()).setBody("MIRROR").execute().get();
            assertEquals(response.getStatusCode(), 200);
            assertEquals(new String(response.getResponseBodyAsBytes(), UTF_8), "MIRROR");
        } finally {
            client.close();
        }
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.