Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpState


        assertNull(authstate.getRealm());
        assertTrue(authstate.isPreemptive());
    }

    public void testPreemptiveAuthorizationTrueWithoutCreds() throws Exception {
        HttpState state = new HttpState();
        this.client.setState(state);
        this.client.getParams().setAuthenticationPreemptive(true);
        this.server.setHttpService(new BasicAuthService());
        GetMethod httpget = new GetMethod("/test/");
        try {
View Full Code Here


        assertNotNull(authstate.getRealm());
        assertFalse(authstate.isPreemptive());
    }

    public void testBasicAuthenticationCaseInsensitivity() throws Exception {
        HttpState state = new HttpState();
        AuthScope authscope = new AuthScope(
            this.server.getLocalAddress(),
            this.server.getLocalPort(),
            "test");
        state.setCredentials(authscope, new UsernamePasswordCredentials("test", "test"));
        this.client.setState(state);
        this.server.setHttpService(new BasicAuthService3());
        GetMethod httpget = new GetMethod("/test/");
        try {
            this.client.executeMethod(httpget);
View Full Code Here

            // Initialize HttpClient
            HttpClient httpClient = new HttpClient();

            // Set cookies
            if ((transferedCookies != null) && (transferedCookies.length > 0)) {
                HttpState httpState = new HttpState();
                httpState.addCookies(transferedCookies);
                httpClient.setState(httpState);
            }

            // DEBUG cookies
            // Send request to servlet
View Full Code Here

        httpMethod.setHttp11(!JMeterUtils.getPropDefault("httpclient.version","1.1").equals("1.0"));

        // Set the timeout (if non-zero)
        httpConn.setSoTimeout(JMeterUtils.getPropDefault("httpclient.timeout",0));

        httpState = new HttpState();
        if (httpConn.isProxied() && httpConn.isSecure()) {
            httpMethod = new ConnectMethod(httpMethod);
        }
       
        // Allow HttpClient to handle the redirects:
View Full Code Here

        subscribeMethod.addRequestHeader(SubscribeMethod.H_NOTIFICATION_DELAY, String.valueOf(notificationDelay));
        subscribeMethod.addRequestHeader(SubscribeMethod.H_SUBSCRIPTION_LIFETIME, String.valueOf(lifetime));
        subscribeMethod.addRequestHeader(SubscribeMethod.H_DEPTH, ((depth == DepthSupport.DEPTH_INFINITY ) ? "infinity" : String.valueOf(depth)));
        try {
            subscribeMethod.setDoAuthentication(true);
            HttpState httpState = new HttpState();
            httpState.setCredentials(null, repositoryHost, credentials);
            HttpConnection httpConnection = new HttpConnection(repositoryHost, repositoryPort, protocol);
            httpConnection.setConnectionTimeout(CONNECTION_TIMEOUT);
            int state = subscribeMethod.execute(httpState, httpConnection);
            if ( state == HttpStatus.SC_OK ) {
                String subscriptionId = subscribeMethod.getResponseHeader(SubscribeMethod.H_SUBSCRIPTION_ID).getValue();
View Full Code Here

                if ( subscription.getSubscriber().equals(listener) ) {
                    String id = String.valueOf(subscription.getId());
                    unsubscribeMethod.addRequestHeader(UnsubscribeMethod.H_SUBSCRIPTION_ID, id);
                    try {
                        unsubscribeMethod.setDoAuthentication(true);
                        HttpState httpState = new HttpState();
                        httpState.setCredentials(null, repositoryHost, credentials);
                        HttpConnection httpConnection = new HttpConnection(repositoryHost, repositoryPort, protocol);
                        httpConnection.setConnectionTimeout(CONNECTION_TIMEOUT);
                        int state = unsubscribeMethod.execute(httpState, httpConnection);
                        if ( state == HttpStatus.SC_OK ) {
                            i.remove();
View Full Code Here

        fireEvent(eventMethod, credentials);
    }

    protected void fireEvent(EventMethod eventMethod, Credentials credentials) throws IOException {
        eventMethod.setDoAuthentication(true);
        HttpState httpState = new HttpState();
        httpState.setCredentials(null, repositoryHost, credentials);
        int state = eventMethod.execute(httpState, new HttpConnection(repositoryHost, repositoryPort, protocol));
        if ( state == HttpStatus.SC_OK ) {
        } else {
            logger.log(Level.SEVERE, "Event failed. State: "+state);
        }
View Full Code Here

            logger.log(Level.INFO, "Poll for subscribers: "+pollSubscribers);
            PollMethod pollMethod = new PollMethod(repositoryDomain+"/");
            pollMethod.addRequestHeader(SubscribeMethod.H_SUBSCRIPTION_ID, pollSubscribers);
            try {
                pollMethod.setDoAuthentication(true);
                HttpState httpState = new HttpState();
                httpState.setCredentials(null, repositoryHost, credentials);
              HttpConnection httpConnection = new HttpConnection(repositoryHost, repositoryPort, protocol);
              httpConnection.setConnectionTimeout(CONNECTION_TIMEOUT);
                int state = pollMethod.execute(httpState, httpConnection);
                if ( state == HttpStatus.SC_MULTI_STATUS ) {
                    List events = pollMethod.getEvents();
View Full Code Here

                                                        httpURL.getPassword());
                }
            }

            if (hostCredentials != null) {
                HttpState clientState = client.getState();
                clientState.setCredentials(null, httpURL.getHost(),
                                           hostCredentials);
                clientState.setAuthenticationPreemptive(true);
            }

            if (proxyCredentials != null) {
                client.getState().setProxyCredentials(null, proxyHost,
                                                      proxyCredentials);
View Full Code Here

       

        // TODO make this a JMeter property
        httpMethod.setHttp11(!System.getProperty("http.version","1.1").equals("1.0"));

        httpState = new HttpState();
        if (httpConn.isProxied() && httpConn.isSecure()) {
            httpMethod = new ConnectMethod(httpMethod);
        }
       
        // Allow HttpClient to handle the redirects:
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.HttpState

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.