Package org.apache.cxf.transports.http.configuration

Examples of org.apache.cxf.transports.http.configuration.HTTPClientPolicy


     */
    private void setHeadersByClientPolicy(
        Message message,
        Map<String, List<String>> headers
    ) {
        HTTPClientPolicy policy = getClient(message);
        if (policy == null) {
            return;
        }
        if (policy.isSetCacheControl()) {
            headers.put("Cache-Control",
                        createMutableList(policy.getCacheControl()));
        }
        if (policy.isSetHost()) {
            headers.put("Host",
                        createMutableList(policy.getHost()));
        }
        if (policy.isSetConnection()) {
            headers.put("Connection",
                        createMutableList(policy.getConnection().value()));
        }
        if (policy.isSetAccept()) {
            headers.put("Accept",
                        createMutableList(policy.getAccept()));
        } else if (!headers.containsKey("Accept")) {
            headers.put("Accept", createMutableList("*/*"));
        }
        if (policy.isSetAcceptEncoding()) {
            headers.put("Accept-Encoding",
                        createMutableList(policy.getAcceptEncoding()));
        }
        if (policy.isSetAcceptLanguage()) {
            headers.put("Accept-Language",
                        createMutableList(policy.getAcceptLanguage()));
        }
        if (policy.isSetContentType()) {
            message.put(Message.CONTENT_TYPE, policy.getContentType());
        }
        if (policy.isSetCookie()) {
            headers.put("Cookie",
                        createMutableList(policy.getCookie()));
        }
        if (policy.isSetBrowserType()) {
            headers.put("BrowserType",
                        createMutableList(policy.getBrowserType()));
        }
        if (policy.isSetReferer()) {
            headers.put("Referer",
                        createMutableList(policy.getReferer()));
        }
    }
View Full Code Here


    ) throws IOException {
       
        // Disconnect the old, and in with the new.
        connection.disconnect();
       
        HTTPClientPolicy cp = getClient(message);
        connection = getConnectionFactory(newURL).createConnection(getProxy(cp, newURL), newURL);
        connection.setDoOutput(true);       
        // TODO: using Message context to deceided HTTP send properties
        connection.setConnectTimeout((int)cp.getConnectionTimeout());
        connection.setReadTimeout((int)cp.getReceiveTimeout());
        connection.setUseCaches(false);
        connection.setInstanceFollowRedirects(false);

        // If the HTTP_REQUEST_METHOD is not set, the default is "POST".
        String httpRequestMethod =
View Full Code Here

                             + new String(cachedStream.getBytes()));
                }

                HttpURLConnection oldcon = connection;
               
                HTTPClientPolicy policy = getClient(outMessage);
               
                // Default MaxRetransmits is -1 which means unlimited.
                int maxRetransmits = (policy == null)
                                     ? -1
                                     : policy.getMaxRetransmits();

                // evaluate "Set-Cookie" headers before handling retransmits
                if (maintainSession) {
                    for (Map.Entry<String, List<String>> h : connection.getHeaderFields().entrySet()) {
                        if ("Set-Cookie".equalsIgnoreCase(h.getKey())) {
View Full Code Here

     */
    private void setHeadersByClientPolicy(
        Message message,
        Map<String, List<String>> headers
    ) {
        HTTPClientPolicy policy = getClient(message);
        if (policy == null) {
            return;
        }
        if (policy.isSetCacheControl()) {
            headers.put("Cache-Control",
                        createMutableList(policy.getCacheControl().value()));
        }
        if (policy.isSetHost()) {
            headers.put("Host",
                        createMutableList(policy.getHost()));
        }
        if (policy.isSetConnection()) {
            headers.put("Connection",
                        createMutableList(policy.getConnection().value()));
        }
        if (policy.isSetAccept()) {
            headers.put("Accept",
                        createMutableList(policy.getAccept()));
        } else if (!headers.containsKey("Accept")) {
            headers.put("Accept", createMutableList("*/*"));
        }
        if (policy.isSetAcceptEncoding()) {
            headers.put("Accept-Encoding",
                        createMutableList(policy.getAcceptEncoding()));
        }
        if (policy.isSetAcceptLanguage()) {
            headers.put("Accept-Language",
                        createMutableList(policy.getAcceptLanguage()));
        }
        if (policy.isSetContentType()) {
            message.put(Message.CONTENT_TYPE, policy.getContentType());
        }
        if (policy.isSetCookie()) {
            headers.put("Cookie",
                        createMutableList(policy.getCookie()));
        }
        if (policy.isSetBrowserType()) {
            headers.put("BrowserType",
                        createMutableList(policy.getBrowserType()));
        }
        if (policy.isSetReferer()) {
            headers.put("Referer",
                        createMutableList(policy.getReferer()));
        }
    }
View Full Code Here

    ) throws IOException {
       
        // Disconnect the old, and in with the new.
        connection.disconnect();
       
        HTTPClientPolicy cp = getClient(message);
        connection = getConnectionFactory(newURL).createConnection(getProxy(cp), newURL);
        connection.setDoOutput(true);       
        // TODO: using Message context to deceided HTTP send properties
        connection.setConnectTimeout((int)cp.getConnectionTimeout());
        connection.setReadTimeout((int)cp.getReceiveTimeout());
        connection.setUseCaches(false);
        connection.setInstanceFollowRedirects(false);

        // If the HTTP_REQUEST_METHOD is not set, the default is "POST".
        String httpRequestMethod =
View Full Code Here

                             + new String(cachedStream.getBytes()));
                }

                HttpURLConnection oldcon = connection;
               
                HTTPClientPolicy policy = getClient(outMessage);
               
                // Default MaxRetransmits is -1 which means unlimited.
                int maxRetransmits = (policy == null)
                                     ? -1
                                     : policy.getMaxRetransmits();
               
                // MaxRetransmits of zero means zero.
                if (maxRetransmits == 0) {
                    return;
                }
View Full Code Here

        }
       
        GreetMeLater later = new GreetMeLater();
        later.setRequestType(1000);
       
        HTTPClientPolicy pol = new HTTPClientPolicy();
        pol.setReceiveTimeout(100);
        disp.getRequestContext().put(HTTPClientPolicy.class.getName(), pol);
        Response<Object> o = disp.invokeAsync(later);
        try {
            o.get(10, TimeUnit.SECONDS);
            fail("Should have gotten a SocketTimeoutException");
        } catch (ExecutionException ex) {
            assertTrue(ex.getCause() instanceof SocketTimeoutException);
        }

        later.setRequestType(20000);
        pol.setReceiveTimeout(20000);
        disp.getRequestContext().put(HTTPClientPolicy.class.getName(), pol);
        o = disp.invokeAsync(later);
        try {
            o.get(100, TimeUnit.MILLISECONDS);
            fail("Should have gotten a SocketTimeoutException");
View Full Code Here

                        }
                        mo.onMessage(outMessage);
                    }
                }
            };
            HTTPClientPolicy policy = getClient(outMessage);
            try {
                Executor ex = outMessage.getExchange().get(Executor.class);
                if (forceWQ && ex != null) {
                    final Executor ex2 = ex;
                    final Runnable origRunnable = runnable;
                    runnable = new Runnable() {
                        public void run() {
                            outMessage.getExchange().put(Executor.class.getName()
                                                         + ".USING_SPECIFIED", Boolean.TRUE);
                            ex2.execute(origRunnable);
                        }
                    };
                }
                if (ex == null || forceWQ) {
                    WorkQueueManager mgr = outMessage.getExchange().get(Bus.class)
                        .getExtension(WorkQueueManager.class);
                    AutomaticWorkQueue qu = mgr.getNamedWorkQueue("http-conduit");
                    if (qu == null) {
                        qu = mgr.getAutomaticWorkQueue();
                    }
                    long timeout = 1000;
                    if (policy != null && policy.isSetAsyncExecuteTimeout()) {
                        timeout = policy.getAsyncExecuteTimeout();
                    }
                    if (timeout > 0) {
                        qu.execute(runnable, timeout);
                    } else {
                        qu.execute(runnable);
                    }
                } else {
                    outMessage.getExchange().put(Executor.class.getName()
                                             + ".USING_SPECIFIED", Boolean.TRUE);
                    ex.execute(runnable);
                }
            } catch (RejectedExecutionException rex) {
                if (allowCurrentThread
                    && policy != null
                    && policy.isSetAsyncExecuteTimeoutRejection()
                    && policy.isAsyncExecuteTimeoutRejection()) {
                    throw rex;
                }
                if (!hasLoggedAsyncWarning) {
                    LOG.warning("EXECUTOR_FULL_WARNING");
                    hasLoggedAsyncWarning = true;
View Full Code Here


       

        private int getMaxRetransmits() {
            HTTPClientPolicy policy = getClient(outMessage);
            // Default MaxRetransmits is -1 which means unlimited.
            return (policy == null) ? -1 : policy.getMaxRetransmits();
        }
View Full Code Here

    private static void configureConduitFromEndpointInfo(HTTPConduit conduit,
            EndpointInfo endpointInfo) {
        if (conduit.getClient() == null) {
            conduit.setClient(endpointInfo.getTraversedExtensor(
                    new HTTPClientPolicy(), HTTPClientPolicy.class));
        }
        if (conduit.getAuthorization() == null) {
            conduit.setAuthorization(endpointInfo.getTraversedExtensor(
                    new AuthorizationPolicy(), AuthorizationPolicy.class));
View Full Code Here

TOP

Related Classes of org.apache.cxf.transports.http.configuration.HTTPClientPolicy

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.