Package org.apache.commons.httpclient.methods

Examples of org.apache.commons.httpclient.methods.HeadMethod.addRequestHeader()


   @Test
   public void testHead() throws Exception
   {
      HttpClient client = new HttpClient();
      HeadMethod method = new HeadMethod(TestPortProvider.generateURL("/GetTest"));
      method.addRequestHeader("Accept", "text/plain");
      int status = client.executeMethod(method);
      Assert.assertEquals(200, status);
      Header header = method.getResponseHeader("CTS-HEAD");
      Assert.assertNotNull(header);
      Assert.assertEquals("text-plain", header.getValue());
View Full Code Here


   @Test
   public void testHead2() throws Exception
   {
      HttpClient client = new HttpClient();
      HeadMethod method = new HeadMethod(TestPortProvider.generateURL("/GetTest"));
      method.addRequestHeader("Accept", "text/html");
      int status = client.executeMethod(method);
      Assert.assertEquals(200, status);
      Header header = method.getResponseHeader("CTS-HEAD");
      Assert.assertNotNull(header);
      Assert.assertEquals("text-html", header.getValue());
View Full Code Here

   @Test
   public void testHeadSubresource() throws Exception
   {
      HttpClient client = new HttpClient();
      HeadMethod method = new HeadMethod(TestPortProvider.generateURL("/GetTest/sub"));
      method.addRequestHeader("Accept", "text/plain");
      int status = client.executeMethod(method);
      Assert.assertEquals(200, status);
      Header header = method.getResponseHeader("CTS-HEAD");
      Assert.assertNotNull(header);
      Assert.assertEquals("sub-text-plain", header.getValue());
View Full Code Here

    }

    /** {@inheritDoc} */
    public boolean exists() throws ResourceException {
        HeadMethod headMethod = new HeadMethod(resourceUrl);
        headMethod.addRequestHeader("Connection", "close");

        try {
            httpClient.executeMethod(headMethod);
            if (headMethod.getStatusCode() != HttpStatus.SC_OK) {
                return false;
View Full Code Here

    }

    /** {@inheritDoc} */
    public DateTime getLastModifiedTime() throws ResourceException {
        HeadMethod headMethod = new HeadMethod(resourceUrl);
        headMethod.addRequestHeader("Connection", "close");

        try {
            httpClient.executeMethod(headMethod);
            if (headMethod.getStatusCode() != HttpStatus.SC_OK) {
                throw new ResourceException("Unable to retrieve resource URL " + resourceUrl
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.