Examples of HttpState


Examples of org.apache.commons.httpclient.HttpState

       
        HttpRequestHandlerChain handlerchain = new HttpRequestHandlerChain();
        handlerchain.appendHandler(new AuthRequestHandler(creds));
        handlerchain.appendHandler(new HttpServiceHandler(new EchoService()));

        HttpState state = new HttpState();
        AuthScope authscope = new AuthScope(
            this.server.getLocalAddress(),
            this.server.getLocalPort(),
            "test");
        state.setCredentials(authscope, creds);
        this.client.setState(state);

        this.server.setRequestHandler(handlerchain);

        PutMethod put = new PutMethod("/test/");
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

            "name1=value1;Version=1;Path=/commons,name1=value2;Version=1;" +
            "Path=/commons/httpclient;Version=1");

        CookieSpec cookiespec = new CookieSpecBase();
        Cookie[] parsed = cookieParse(cookiespec, ".apache.org", 80, "/commons/httpclient", true, header);
        HttpState state = new HttpState();
        state.addCookies(parsed);
        Cookie[] cookies = state.getCookies();
        assertEquals("Wrong number of cookies.",2,cookies.length);
        assertEquals("Name","name1",cookies[0].getName());
        assertEquals("Value","value1",cookies[0].getValue());
        assertEquals("Name","name1",cookies[1].getName());
        assertEquals("Value","value2",cookies[1].getValue());
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

        Header header = new Header("Set-Cookie",
            "name1=value1;Version=1;Path=/commons,name1=value2;Version=1;Path=/commons");

        CookieSpec cookiespec = new CookieSpecBase();
        Cookie[] parsed = cookieParse(cookiespec, ".apache.org", 80, "/commons/httpclient", true, header);
        HttpState state = new HttpState();
        state.addCookies(parsed);
        Cookie[] cookies = state.getCookies();
        assertEquals("Found 1 cookies.",1,cookies.length);
        assertEquals("Name","name1",cookies[0].getName());
        assertEquals("Value","value2",cookies[0].getValue());
    }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

            return;
        }

        /* Call up the remote HTTP server */
        HttpConnection connection = new HttpConnection(this.method.getHostConfiguration());
        HttpState state = new HttpState();
        this.method.setFollowRedirects(true);
        int status = this.method.execute(state, connection);
        if (status == 404) {
            throw new ResourceNotFoundException("Unable to access \"" + this.method.getURI()
                    + "\" (HTTP 404 Error)");
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

                hostConfig.setProxy(proxyHost, proxyPort);

            String userName = httpURL.getUser();
            if (userName != null && userName.length() > 0) {
                String password = httpURL.getPassword();
                HttpState clientState = client.getState();
                clientState.setCredentials(null, httpURL.getHost(),
                    new UsernamePasswordCredentials(userName, password));
                clientState.setAuthenticationPreemptive(true);
            }

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

Examples of org.apache.commons.httpclient.HttpState

                    new Header("Content-type", "text/xml; charset=\"utf-8\""));
            method.setRequestHeader(new Header("SOAPAction", action));
            method.setUseDisk(false);
            method.setRequestBody(request);

            method.execute(new HttpState(), conn);

            String ret = method.getResponseBodyAsString();
            int startOfXML = ret.indexOf("<?xml");
            if (startOfXML == -1) { // No xml?!
                throw new ProcessingException("Invalid response - no xml");
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

        assertEquals("Basic ZGg65C32Lfw=",
            BasicScheme.authenticate(credentials, "ISO-8859-1"));
    }
   
    public void testBasicAuthenticationWithDefaultCreds() throws Exception {
        HttpState state = new HttpState();
        state.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("test", "test"));
        this.client.setState(state);
        this.server.setHttpService(new BasicAuthService());
        GetMethod httpget = new GetMethod("/test/");
        try {
            this.client.executeMethod(httpget);
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

        assertTrue(authstate.getAuthScheme() instanceof BasicScheme);
        assertEquals("test", authstate.getRealm());
    }

    public void testBasicAuthentication() 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 BasicAuthService());
        GetMethod httpget = new GetMethod("/test/");
        try {
            this.client.executeMethod(httpget);
View Full Code Here

Examples of org.apache.commons.httpclient.HttpState

        assertTrue(authstate.getAuthScheme() instanceof BasicScheme);
        assertEquals("test", authstate.getRealm());
    }

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

Examples of org.apache.commons.httpclient.HttpState

        assertTrue(authstate.getAuthScheme() instanceof BasicScheme);
        assertEquals("test", authstate.getRealm());
    }

    public void testBasicAuthenticationWithMutlipleRealms() throws Exception {
        HttpState state = new HttpState();
        AuthScope realm1 = new AuthScope(
            this.server.getLocalAddress(),
            this.server.getLocalPort(),
            "test");
        AuthScope realm2 = new AuthScope(
            this.server.getLocalAddress(),
            this.server.getLocalPort(),
            "test2");
        state.setCredentials(realm1, new UsernamePasswordCredentials("test","test"));
        state.setCredentials(realm2, new UsernamePasswordCredentials("test2","test2"));
        this.client.setState(state);
        {
            this.server.setHttpService(new BasicAuthService());
            GetMethod httpget = new GetMethod("/test/");
            try {
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.