Examples of HeadMethod


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 {
            client.executeMethod(headMethod);
View Full Code Here

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

        state.setCredentials(AuthScope.ANY, cred);
        HostConfiguration hc = new HostConfiguration();
        hc.setHost(getHost(), getPort(), getProtocol());
        client.setHostConfiguration(hc);
        client.setState(state);
        HeadMethod method = new HeadMethod("/"+ getWebappContext() +"/auth/basic");
        client.executeMethod(method);
        method.releaseConnection();
        assertEquals(200, method.getStatusCode());
    }
View Full Code Here

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

        if (method.equals(POST)) {
            httpMethod = new PostMethod(urlStr);
        } else if (method.equals(PUT)) {
            httpMethod = new PutMethod(urlStr);
        } else if (method.equals(HEAD)) {
            httpMethod = new HeadMethod(urlStr);
        } else if (method.equals(TRACE)) {
            httpMethod = new TraceMethod(urlStr);
        } else if (method.equals(OPTIONS)) {
            httpMethod = new OptionsMethod(urlStr);
        } else if (method.equals(DELETE)) {
View Full Code Here

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

    * @throws HttpException
    */
   public static boolean resourceExists(HttpClient client, HttpURL httpURL)
      throws IOException, HttpException
   {
      HeadMethod head = new HeadMethod(httpURL.getURI());
      head.setFollowRedirects(true);
      int status = client.executeMethod(head);
     
      switch (status) {
         case WebdavStatus.SC_OK:
            return true;
         case WebdavStatus.SC_NOT_FOUND:
            return false;
         default:
            HttpException ex = new HttpException();
            ex.setReasonCode(status);
            ex.setReason(head.getStatusText());
            throw ex;
      }
   }
View Full Code Here

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

     */
    public boolean headMethod(String path)
        throws HttpException, IOException {

        setClient();
        HeadMethod method = new HeadMethod(URIUtil.encodePathQuery(path));

        generateTransactionHeader(method);
        int statusCode = client.executeMethod(method);

        setStatusCode(statusCode);
View Full Code Here

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

     */
    protected FileType doGetType()
        throws Exception
    {
        // Use the HEAD method to probe the file.
        method = new HeadMethod();
        setupMethod(method);
        final HttpClient client = fileSystem.getClient();
        final int status = client.executeMethod(method);
        method.releaseConnection();
        if (status == HttpURLConnection.HTTP_OK)
View Full Code Here

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

                final UsernamePasswordCredentials creds =
                    new UsernamePasswordCredentials(username, password);
                client.getState().setCredentials(null, hostname, creds);
            }

            client.executeMethod(new HeadMethod());
        }
        catch (final Exception exc)
        {
            throw new FileSystemException("vfs.provider.http/connect.error", new Object[]{hostname}, exc);
        }
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

        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

      switch(m) {
        case GET:     httpMethod = new GetMethod(uri); break;
        case POST:    httpMethod = getMethod(new PostMethod(uri), entity); break;
        case PUT:     httpMethod = getMethod(new PutMethod(uri), entity); break;
        case DELETE:  httpMethod = new DeleteMethod(uri); break;
        case HEAD:    httpMethod = new HeadMethod(uri); break;
        case OPTIONS: httpMethod = new OptionsMethod(uri); break;
        case TRACE:   httpMethod = new TraceMethod(uri); break;
        default:      httpMethod = getMethod(new ExtensionMethod(method,uri), entity);
      }
      initHeaders(options, httpMethod);
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.