Package org.asynchttpclient

Examples of org.asynchttpclient.Request


        } else {
            orig = Uri.create(httpTransactionContext.getRequest().getUri(),
                    httpTransactionContext.getLastRedirectURI());
        }
        httpTransactionContext.setLastRedirectURI(redirectURL);
        Request requestToSend;
        Uri uri = Uri.create(orig, redirectURL);
        if (!uri.toUrl().equalsIgnoreCase(orig.toUrl())) {
            requestToSend = EventHandler.newRequest(uri, responsePacket, httpTransactionContext,
                    sendAsGet(responsePacket, httpTransactionContext));
        } else {
            httpTransactionContext.setStatusHandler(null);
            httpTransactionContext.setInvocationStatus(CONTINUE);
            try {
                httpTransactionContext.getHandler().onStatusReceived(httpTransactionContext.getResponseStatus());
            } catch (Exception e) {
                httpTransactionContext.abort(e);
            }
            return true;
        }

        final ConnectionManager m = httpTransactionContext.getProvider().getConnectionManager();
        try {
            final Connection c = m.obtainConnection(requestToSend, httpTransactionContext.getFuture());
            final HttpTxContext newContext = httpTransactionContext.copy();
            httpTransactionContext.setFuture(null);
            newContext.setInvocationStatus(CONTINUE);
            newContext.setRequest(requestToSend);
            newContext.setRequestUri(requestToSend.getUri());
            HttpTxContext.set(ctx, newContext);
            httpTransactionContext.getProvider().execute(c, requestToSend, newContext.getHandler(), newContext.getFuture(), newContext);
            return false;
        } catch (Exception e) {
            httpTransactionContext.abort(e);
View Full Code Here


    @Test(groups = { "standalone", "default_provider", "async" })
    public void asyncProviderEncodingTest() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Request request = new RequestBuilder("GET").setUrl(getTargetUrl() + "?q=+%20x").build();
            assertEquals(request.getUrl(), getTargetUrl() + "?q=%20%20x");

            String url = client.executeRequest(request, new AsyncCompletionHandler<String>() {
                @Override
                public String onCompleted(Response response) throws Exception {
                    return response.getUri().toString();
View Full Code Here

    @Test(groups = { "standalone", "default_provider", "async" })
    public void asyncProviderEncodingTest2() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Request request = new RequestBuilder("GET").setUrl(getTargetUrl() + "").addQueryParam("q", "a b").build();

            String url = client.executeRequest(request, new AsyncCompletionHandler<String>() {
                @Override
                public String onCompleted(Response response) throws Exception {
                    return response.getUri().toString();
View Full Code Here

    @Test(groups = { "standalone", "default_provider", "async" })
    public void emptyRequestURI() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Request request = new RequestBuilder("GET").setUrl(getTargetUrl()).build();

            String url = client.executeRequest(request, new AsyncCompletionHandler<String>() {
                @Override
                public String onCompleted(Response response) throws Exception {
                    return response.getUri().toString();
View Full Code Here

        final int ct = connection.getContentLength();
        connection.disconnect();
        try {
            final CountDownLatch l = new CountDownLatch(1);

            Request request = new RequestBuilder("GET").setUrl(getTargetUrl()).build();
            client.executeRequest(request, new AsyncCompletionHandlerAdapter() {

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

    @Test(groups = { "standalone", "default_provider", "async" })
    public void asyncContentTypeGETTest() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            final CountDownLatch l = new CountDownLatch(1);
            Request request = new RequestBuilder("GET").setUrl(getTargetUrl()).build();
            client.executeRequest(request, new AsyncCompletionHandlerAdapter() {

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

    @Test(groups = { "standalone", "default_provider", "async" })
    public void asyncHeaderGETTest() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            final CountDownLatch l = new CountDownLatch(1);
            Request request = new RequestBuilder("GET").setUrl(getTargetUrl()).build();
            client.executeRequest(request, new AsyncCompletionHandlerAdapter() {

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

            h.add("Test1", "Test1");
            h.add("Test2", "Test2");
            h.add("Test3", "Test3");
            h.add("Test4", "Test4");
            h.add("Test5", "Test5");
            Request request = new RequestBuilder("GET").setUrl(getTargetUrl()).setHeaders(h).build();

            client.executeRequest(request, new AsyncCompletionHandlerAdapter() {

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

            Map<String, List<String>> m = new HashMap<String, List<String>>();
            for (int i = 0; i < 5; i++) {
                m.put("param_" + i, Arrays.asList("value_" + i));
            }
            Request request = new RequestBuilder("POST").setUrl(getTargetUrl()).setHeaders(h).setFormParams(m).build();
            client.executeRequest(request, new AsyncCompletionHandlerAdapter() {

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

    @Test(groups = { "standalone", "default_provider", "async" })
    public void asyncStatusHEADTest() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            final CountDownLatch l = new CountDownLatch(1);
            Request request = new RequestBuilder("HEAD").setUrl(getTargetUrl()).build();
            Response response = client.executeRequest(request, new AsyncCompletionHandlerAdapter() {

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

TOP

Related Classes of org.asynchttpclient.Request

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.