Examples of HeadMethod


Examples of org.apache.commons.httpclient.methods.HeadMethod

            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        String path = "/";
        HeadMethod method = new HeadMethod(path);

        try {
            client.executeMethod(method);
        } catch (Throwable t) {
            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        assertEquals(200, method.getStatusCode());

        method = new HeadMethod(path);

        try {
            client.executeMethod(method);
        } catch (Throwable t) {
            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        assertEquals(200, method.getStatusCode());

    }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.HeadMethod

            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        String path = "/";
        HeadMethod method = new HeadMethod(path);

        try {
            client.executeMethod(method);
        } catch (Throwable t) {
            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        assertEquals(200, method.getStatusCode());

        method = new HeadMethod(path);

        try {
            client.executeMethod(method);
        } catch (Throwable t) {
            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        assertEquals(200, method.getStatusCode());

    }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.HeadMethod

        state.setCredentials(authscope, creds);
        this.client.setState(state);

        this.server.setRequestHandler(handlerchain);

        HeadMethod head = new HeadMethod("/test/");
        try {
            this.client.executeMethod(head);
        } finally {
            head.releaseConnection();
        }
        assertNotNull(head.getStatusLine());
        assertEquals(HttpStatus.SC_OK, head.getStatusLine().getStatusCode());
        Header auth = head.getRequestHeader("Authorization");
        assertNotNull(auth);
        String expected = "Basic " + EncodingUtil.getAsciiString(
            Base64.encodeBase64(EncodingUtil.getAsciiBytes("testuser:testpass")));
        assertEquals(expected, auth.getValue());
        AuthState authstate = head.getHostAuthState();
        assertNotNull(authstate.getAuthScheme());
        assertTrue(authstate.getAuthScheme() instanceof BasicScheme);
        assertEquals("test", authstate.getRealm());
    }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.HeadMethod

        }
    }

    public Map<String, String> loadHeaders(String uri, String[] headerNames) throws IOException,
            RepositoryException {
        HeadMethod method = new HeadMethod(uri);
        try {
            int statusCode = client.executeMethod(method);
            if (statusCode == DavServletResponse.SC_OK) {
                Map<String, String> headers = new HashMap<String, String>();
                for (String name : headerNames) {
                    headers.put(name, method.getResponseHeader(name).getValue());
                }
                return headers;
            } else {
                throw ExceptionConverter.generate(new DavException(statusCode, ("Unable to load headers at " + uri + " - Status line = " + method.getStatusLine().toString())));
            }
        } finally {
            method.releaseConnection();
        }
    }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.HeadMethod

        update(uri, relPath, new String[] {vUri}, UpdateInfo.UPDATE_BY_VERSION, removeExisting, sessionInfo);
    }

    private boolean exists(SessionInfo sInfo, String uri) {
        HeadMethod method = new HeadMethod(uri);
        try {
            int statusCode = getClient(sInfo).executeMethod(method);
            if (statusCode == DavServletResponse.SC_OK) {
                return true;
            }
        } catch (IOException e) {
            log.error("Unexpected error while testing existence of item.",e);
        } catch (RepositoryException e) {
            log.error(e.getMessage());
        } finally {
            method.releaseConnection();
        }
        return false;
    }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.HeadMethod

            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        String path = "/" + webAppContext + "/body";
        HeadMethod method = new HeadMethod(path);

        try {
            client.executeMethod(method);
        } catch (Throwable t) {
            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        assertEquals(200, method.getStatusCode());

        method.recycle();
        method.setPath(path);

        try {
            client.executeMethod(method);
        } catch (Throwable t) {
            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        assertEquals(200, method.getStatusCode());

    }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.HeadMethod

        state.setCredentials(null, cred);
        HostConfiguration hc = new HostConfiguration();
        hc.setHost(host, port, "http");
        client.setHostConfiguration(hc);
        client.setState(state);
        HeadMethod method = new HeadMethod("/"+ webAppContext +"/auth/basic");
        client.executeMethod(method);
        method.releaseConnection();
        assertEquals(200, method.getStatusCode());
    }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.HeadMethod

        }
        conn.assertNotOpen();

        // note - this test is here because the HEAD method handler overrides the
        // standard behavior for reading a response body.
        HeadMethod headMethod = new HeadMethod("/");

        conn.addResponse(headers, "");

        try {
            headMethod.execute(new HttpState(), conn);
            conn.assertNotOpen();

        } catch (Throwable t) {
            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
View Full Code Here

Examples of org.apache.commons.httpclient.methods.HeadMethod

        } else if (request.getMethodName() == HttpMethodName.DELETE) {
            DeleteMethod deleteMethod = new DeleteMethod(uri);
            if (nameValuePairs != null) deleteMethod.setQueryString(nameValuePairs);
            method = deleteMethod;
        } else if (request.getMethodName() == HttpMethodName.HEAD) {
            HeadMethod headMethod = new HeadMethod(uri);
            if (nameValuePairs != null) headMethod.setQueryString(nameValuePairs);
            method = headMethod;
        } else {
            throw new AmazonClientException("Unknown HTTP method name: " + request.getMethodName());
        }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.HeadMethod

        config.setAll( methodConfig );

        TestWagon wagon = new TestWagon();
        wagon.setHttpConfiguration( config );

        HeadMethod method = new HeadMethod();
        wagon.setParameters( method );

        HttpMethodParams params = method.getParams();
        assertNotNull( params );
        assertTrue( params.isParameterTrue( HttpClientParams.PREEMPTIVE_AUTHENTICATION ) );
    }
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.