Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.Header


      logout.setFollowRedirects(false);
      int responseCode = httpConn.executeMethod(logout.getHostConfiguration(),
         logout, httpConn.getState());
      assertTrue("Logout: Saw HTTP_MOVED_TEMP("+responseCode+")",
         responseCode == HttpURLConnection.HTTP_MOVED_TEMP);
      Header location = logout.getResponseHeader("Location");
      String indexURI = location.getValue();
      if( indexURI.indexOf("index.html") < 0 )
         fail("get of " + warURL + "Logout not redirected to login page");
   }
View Full Code Here


         formPost, httpConn.getState());
      assertTrue("Saw HTTP_MOVED_TEMP("+responseCode+")",
         responseCode == HttpURLConnection.HTTP_MOVED_TEMP);

      //  Follow the redirect to the index.html page
      Header location = formPost.getResponseHeader("Location");
      String indexURI = location.getValue();
      GetMethod warIndex = new GetMethod(indexURI);
      responseCode = httpConn.executeMethod(warIndex.getHostConfiguration(),
         warIndex, httpConn.getState());
      assertTrue("Get OK", responseCode == HttpURLConnection.HTTP_OK);
      String body = warIndex.getResponseBodyAsString();
View Full Code Here

    */
   public void testUserInRoleServlet() throws Exception
   {
      URL url = new URL(baseURL+"jbosstest/restricted/UserInRoleServlet");
      HttpMethodBase request = HttpUtils.accessURL(url);
      Header errors = request.getResponseHeader("X-ExpectedUserRoles-Errors");
      log.info("X-ExpectedUserRoles-Errors: "+errors);
      assertTrue("X-ExpectedUserRoles-Errors("+errors+") is null", errors == null);
      errors = request.getResponseHeader("X-UnexpectedUserRoles-Errors");
      log.info("X-UnexpectedUserRoles-Errors: "+errors);
      assertTrue("X-UnexpectedUserRoles-Errors("+errors+") is null", errors == null);
View Full Code Here

    */
   public void testSubjectServlet() throws Exception
   {
      URL url = new URL(baseURL+"jbosstest/restricted/SubjectServlet");
      HttpMethodBase request = HttpUtils.accessURL(url);
      Header hdr = request.getResponseHeader("X-SubjectServlet");
      log.info("X-SubjectServlet: "+hdr);
      assertTrue("X-SubjectServlet("+hdr+") is NOT null", hdr != null);
      hdr = request.getResponseHeader("X-SubjectFilter-ENC");
      log.info("X-SubjectFilter-ENC: "+hdr);
      assertTrue("X-SubjectFilter-ENC("+hdr+") is NOT null", hdr != null);
View Full Code Here

      try
      {
         String baseURL = "http://" + getServerHostForURL() + ":" + Integer.getInteger("web.port", 8080) + '/';
         URL url = new URL(baseURL+"manifest/classpath.jsp");
         HttpMethodBase request = HttpUtils.accessURL(url);
         Header errors = request.getResponseHeader("X-Exception");
         log.info("X-Exception: "+errors);
         assertTrue("X-Exception("+errors+") is null", errors == null);
      }
      finally
      {
View Full Code Here

      {
         String baseURL = "http://" + getServerHostForURL() + ":" + Integer.getInteger("web.port", 8080) + '/';
         // Load a log4j class
         URL url = new URL(baseURL+"class-loading/ClasspathServlet2?class=org.apache.log4j.net.SocketAppender");
         HttpMethodBase request = HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK);
         Header cs = request.getResponseHeader("X-CodeSource");
         log.info(cs);
         // Validate it has not come from the war
         assertTrue("X-CodeSource("+cs+") does not contain war",
               cs.getValue().indexOf(".war") < 0 );
         getLog().debug(url+" OK");
      }
      finally
      {
         undeploy("class-loading.war");
View Full Code Here

      {
         String baseURL = "http://" + getServerHostForURL() + ":" + Integer.getInteger("web.port", 8080) + '/';
         // Load a servlet class
         URL url = new URL(baseURL+"servlet-classes/ClasspathServlet2?class=javax.servlet.http.HttpServletResponse");
         HttpMethodBase request = HttpUtils.accessURL(url, REALM, HttpURLConnection.HTTP_OK);
         Header cs = request.getResponseHeader("X-CodeSource");
         log.info(cs);
         // Validate it has not come from the war
         assertTrue("X-CodeSource("+cs+") does not contain war",
               cs.getValue().indexOf(".war") < 0 );
         getLog().debug(url+" OK");
      }
      finally
      {
         undeploy("servlet-classes.war");
View Full Code Here

       HttpClient client = new HttpClient();
       GetMethod method = new GetMethod(EndUserResourceURL + relativeURI);
      
       Base64 base64 = new Base64();
       String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
       method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
      
       int status = client.executeMethod(method);
       if ("/invisible".equals(relativeURI)) {
           if (status != 401) {
               throw new RuntimeException("End user can access the invisible resource");
View Full Code Here

   public String authorizeConsumerRequestToken(String url) throws Exception
   {
      HttpClient client = new HttpClient();
      GetMethod method = new GetMethod(url);
      // request that XML formatted authorization request is presented
      method.addRequestHeader(new Header("Accept", "application/xml"));
      Base64 base64 = new Base64();
      String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
      method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
     
      int status = client.executeMethod(method);
      if (200 != status) {
          throw new RuntimeException("No authorization request data is available");
      }
View Full Code Here

   {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(url);
      Base64 base64 = new Base64();
      String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
      method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
     
      int status = client.executeMethod(method);
      if (302 != status) {
          throw new RuntimeException("Initiation failed");
      }
View Full Code Here

TOP

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

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.