Package org.apache.commons.httpclient.methods

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


   public static final String BASE_URI = "http://localhost:8080/resteasy-cdi/";
  
   public void testPlainTextReadonlyResource(String uri, String body)
   {
      GetMethod get = new GetMethod(uri);
      get.addRequestHeader("Accept", "text/plain");
      try
      {
         int status = client.executeMethod(get);
         assertEquals(200, status);
         assertTrue(get.getResponseBodyAsString().contains(body));
View Full Code Here


   @Test
   public void testTheSameInstanceIsUsedForEveryRequest()
   {
      HttpClient client = new HttpClient();
      GetMethod get1 = new GetMethod(BASE_URI + getTestPrefix());
      get1.addRequestHeader("Accept", "text/plain");
      GetMethod get2 = new GetMethod(BASE_URI + getTestPrefix());
      get2.addRequestHeader("Accept", "text/plain");
      try
      {
         int status1 = client.executeMethod(get1);
View Full Code Here

   {
      HttpClient client = new HttpClient();
      GetMethod get1 = new GetMethod(BASE_URI + getTestPrefix());
      get1.addRequestHeader("Accept", "text/plain");
      GetMethod get2 = new GetMethod(BASE_URI + getTestPrefix());
      get2.addRequestHeader("Accept", "text/plain");
      try
      {
         int status1 = client.executeMethod(get1);
         assertEquals(status1, 200);
         String response1 = get1.getResponseBodyAsString();
View Full Code Here

  
   private void performCustomAuth(String headerId, Cookie cookie,
         String usecase) throws Exception
   {
      GetMethod indexGet = new GetMethod(baseURLNoAuth+path);
      indexGet.addRequestHeader(headerId, "jduke");
      httpConn.getState().addCookie(cookie);
      int responseCode = httpConn.executeMethod(indexGet);
      String response = indexGet.getStatusText();
      log.debug("Response from " + usecase + " case:"+response);
      Header jex = indexGet.getResponseHeader("X-JException");
View Full Code Here

      try
      {
         indexGet = new GetMethod(location);
         indexGet.setFollowRedirects(false);
         // Add the request headers
         indexGet.addRequestHeader("JBOSS_TEST_USER_NAME", "jduke");
         indexGet.addRequestHeader("JBOSS_TEST_CREDENTIAL", "theduke");
         responseCode = httpConn.executeMethod(indexGet);
         assertEquals(HttpURLConnection.HTTP_OK, responseCode);
      }
      finally
View Full Code Here

      {
         indexGet = new GetMethod(location);
         indexGet.setFollowRedirects(false);
         // Add the request headers
         indexGet.addRequestHeader("JBOSS_TEST_USER_NAME", "jduke");
         indexGet.addRequestHeader("JBOSS_TEST_CREDENTIAL", "theduke");
         responseCode = httpConn.executeMethod(indexGet);
         assertEquals(HttpURLConnection.HTTP_OK, responseCode);
      }
      finally
      {
View Full Code Here

    */
   private void performHeaderAuth(String headerId, Cookie cookie, String usecase) throws Exception
   {
      GetMethod method = new GetMethod(this.testAppBaseURL + this.securedServletPath);
      // add the headerId and cookie objects to the request
      method.addRequestHeader(headerId, "jduke");
      this.httpClient.getState().addCookie(cookie);
      // execute the request
      try
      {
         int responseCode = this.httpClient.executeMethod(method);
View Full Code Here

   public void testGzip() throws Exception
   {
      HttpClient client = new HttpClient();
      {
         GetMethod get = new GetMethod("http://localhost:8080/resteasy/gzip");
         get.addRequestHeader("Accept-Encoding", "gzip, deflate");
         int status = client.executeMethod(get);
         Assert.assertEquals(200, status);
         Assert.assertEquals("gzip", get.getResponseHeader("Content-Encoding").getValue());
         GZIPInputStream gzip = new GZIPInputStream(get.getResponseBodyAsStream());
         String response = readString(gzip);
View Full Code Here

   @Test
   public void testNewInstanceCreatedForEveryRequest()
   {
      HttpClient client = new HttpClient();
      GetMethod get1 = new GetMethod(BASE_URI + getTestPrefix() + "toString");
      get1.addRequestHeader("Accept", "text/plain");
      GetMethod get2 = new GetMethod(BASE_URI + getTestPrefix() + "toString");
      get2.addRequestHeader("Accept", "text/plain");
      try
      {
         int status1 = client.executeMethod(get1);
View Full Code Here

   {
      HttpClient client = new HttpClient();
      GetMethod get1 = new GetMethod(BASE_URI + getTestPrefix() + "toString");
      get1.addRequestHeader("Accept", "text/plain");
      GetMethod get2 = new GetMethod(BASE_URI + getTestPrefix() + "toString");
      get2.addRequestHeader("Accept", "text/plain");
      try
      {
         int status1 = client.executeMethod(get1);
         assertEquals(status1, 200);
         String response1 = get1.getResponseBodyAsString();
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.