Package org.asynchttpclient

Examples of org.asynchttpclient.FluentCaseInsensitiveStringsMap


        this.trailingHeaders = traillingHeaders;
        headers = computerHeaders();
    }

    private FluentCaseInsensitiveStringsMap computerHeaders() {
        FluentCaseInsensitiveStringsMap h = new FluentCaseInsensitiveStringsMap();
        for (Map.Entry<String, String> header : responseHeaders) {
            h.add(header.getKey(), header.getValue());
        }

        if (trailingHeaders != null) {
            for (Map.Entry<String, String> header : trailingHeaders) {
                h.add(header.getKey(), header.getValue());
            }
        }

        return h;
    }
View Full Code Here


    public abstract void onError(NettyResponseFuture<?> future, Throwable error);

    public abstract void onClose(NettyResponseFuture<?> future);

    private FluentCaseInsensitiveStringsMap propagatedHeaders(Request request) {
        FluentCaseInsensitiveStringsMap redirectHeaders = new FluentCaseInsensitiveStringsMap();
        for (Map.Entry<String, List<String>> headerEntry : request.getHeaders()) {
            String headerName = headerEntry.getKey();
            List<String> headerValues = headerEntry.getValue();
            if (PROPAGATED_ON_REDIRECT_HEADERS.contains(headerName.toLowerCase(Locale.US)))
                redirectHeaders.add(headerName, headerValues);
        }
        return redirectHeaders;
    }
View Full Code Here

        else
            return bootstrap.connect(remoteAddress);
    }

    private void configureTransferAdapter(AsyncHandler<?> handler, HttpRequest httpRequest) {
        FluentCaseInsensitiveStringsMap h = new FluentCaseInsensitiveStringsMap();
        for (Map.Entry<String, String> entries : httpRequest.headers()) {
            h.add(entries.getKey(), entries.getValue());
        }

        TransferCompletionHandler.class.cast(handler).headers(h);
    }
View Full Code Here

            if (!proxyAuthHeaders.isEmpty()) {
                logger.debug("Sending proxy authentication to {}", request.getUri());

                future.setState(NettyResponseFuture.STATE.NEW);
                Realm newRealm = null;
                FluentCaseInsensitiveStringsMap requestHeaders = request.getHeaders();

                boolean negociate = proxyAuthHeaders.contains("Negotiate");
                String ntlmAuthenticate = getNTLM(proxyAuthHeaders);
                if (!proxyAuthHeaders.contains("Kerberos") && ntlmAuthenticate != null) {
                    newRealm = ntlmProxyChallenge(ntlmAuthenticate, request, proxyServer, requestHeaders, realm, future, true);
View Full Code Here

    }

    private static void compareContentLength(final List<Part> parts) {
        Assert.assertNotNull(parts);
        // get expected values
        final Body multipartBody = MultipartUtils.newMultipartBody(parts, new FluentCaseInsensitiveStringsMap());
        final long expectedContentLength = multipartBody.getContentLength();
        try {
            final ByteBuffer buffer = ByteBuffer.allocate(8192);
            boolean last = false;
            long totalBytes = 0;
View Full Code Here

            if (!l.await(5, TimeUnit.SECONDS)) {
                fail("Timeout out");
            }
           
            FluentCaseInsensitiveStringsMap h = responseHeaders.get();
            assertNotNull(h, "No response headers");
            assertEquals(h.getJoinedValue("content-type", ", "), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET, "Unexpected content-type");
            assertNull(throwable.get(), "Unexpected exception");
           
        } finally {
            c.close();
        }
View Full Code Here

                    return builder.toString().trim();
                }
            });

            String responseBody = f.get(10, TimeUnit.SECONDS);
            FluentCaseInsensitiveStringsMap h = responseHeaders.get();
            assertNotNull(h);
            assertEquals(h.getJoinedValue("content-type", ", "), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET);
            assertEquals(responseBody, RESPONSE);
           
        } finally {
            c.close();
        }
View Full Code Here

                }
            });

            l.await(5, TimeUnit.SECONDS);
            assertTrue(!bodyReceived.get(), "Interrupted not working");
            FluentCaseInsensitiveStringsMap h = responseHeaders.get();
            assertNotNull(h, "Should receive non null headers");
            assertEquals(h.getJoinedValue("content-type", ", ").toLowerCase(Locale.ENGLISH), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET.toLowerCase(Locale.ENGLISH), "Unexpected content-type");
            assertNull(throwable.get(), "Should get an exception");
           
        } finally {
            c.close();
        }
View Full Code Here

                    throwable.set(t);
                }
            });

            String responseBody = f.get(5, TimeUnit.SECONDS);
            FluentCaseInsensitiveStringsMap h = responseHeaders.get();
            assertNotNull(h, "Should receive non null headers");
            assertEquals(h.getJoinedValue("content-type", ", ").toLowerCase(Locale.ENGLISH), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET.toLowerCase(Locale.ENGLISH), "Unexpected content-type");
            assertNotNull(responseBody, "No response body");
            assertEquals(responseBody.trim(), RESPONSE, "Unexpected response body");
            assertNull(throwable.get(), "Unexpected exception");

        } finally {
View Full Code Here

                    return builder.toString();
                }
            });

            String r = f.get(5, TimeUnit.SECONDS);
            FluentCaseInsensitiveStringsMap h = responseHeaders.get();
            assertNotNull(h, "Should receive non null headers");
            assertEquals(h.getJoinedValue("content-type", ", ").toLowerCase(Locale.ENGLISH), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET.toLowerCase(Locale.ENGLISH), "Unexpected content-type");
            assertNotNull(r, "No response body");
            assertEquals(r.trim(), RESPONSE, "Unexpected response body");
           
            responseHeaders.set(null);

            // Let do the same again
            f = rb.execute(new AsyncHandlerAdapter() {
                private StringBuilder builder = new StringBuilder();

                @Override
                public STATE onHeadersReceived(HttpResponseHeaders content) throws Exception {
                    responseHeaders.set(content.getHeaders());
                    return STATE.CONTINUE;
                }

                @Override
                public STATE onBodyPartReceived(HttpResponseBodyPart content) throws Exception {
                    builder.append(new String(content.getBodyPartBytes()));
                    return STATE.CONTINUE;
                }

                @Override
                public String onCompleted() throws Exception {
                    return builder.toString();
                }
            });

            f.get(5, TimeUnit.SECONDS);
            h = responseHeaders.get();
            assertNotNull(h, "Should receive non null headers");
            assertEquals(h.getJoinedValue("content-type", ", ").toLowerCase(Locale.ENGLISH), TEXT_HTML_CONTENT_TYPE_WITH_UTF_8_CHARSET.toLowerCase(Locale.ENGLISH), "Unexpected content-type");
            assertNotNull(r, "No response body");
            assertEquals(r.trim(), RESPONSE, "Unexpected response body");
        } finally {
            c.close();
        }
View Full Code Here

TOP

Related Classes of org.asynchttpclient.FluentCaseInsensitiveStringsMap

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.