Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.Header


      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


      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

   {
      HttpClient client = new HttpClient();
      OptionsMethod method = new OptionsMethod(TestPortProvider.generateURL("/GetTest/sub"));
      int status = client.executeMethod(method);
      Assert.assertEquals(200, status);
      Header allowHeader = method.getResponseHeader("Allow");
      Assert.assertNotNull(allowHeader);
      String allowValue = allowHeader.getValue();
      String[] allowed = allowValue.split(",");
      HashSet set = new HashSet();
      for (String allow : allowed)
      {
         set.add(allow.trim());
View Full Code Here

        httpClient.executeMethod(postMethod);
        Assert.assertEquals(getHttpMethodInfo(postMethod), HttpStatus.SC_CREATED, postMethod.getStatusCode());

        this.unmarshaller.unmarshal(postMethod.getResponseBodyAsStream());

        Header location = postMethod.getResponseHeader("location");

        GetMethod getMethod = executeGet(location.getValue());
        Assert.assertEquals(getHttpMethodInfo(getMethod), HttpStatus.SC_OK, getMethod.getStatusCode());

        Assert.assertEquals(content, getMethod.getResponseBodyAsString());
    }
View Full Code Here

      {
          HttpClient client = new HttpClient();
          PostMethod method = new PostMethod(MessagingServiceCallbackRegistrationURL);
          Base64 base64 = new Base64();
          String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
          method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
          method.addParameter("consumer_id", consumerKey);
          method.addParameter("callback_uri", callback);
          int status = client.executeMethod(method);
          if (HttpResponseCodes.SC_OK != status) {
              throw new RuntimeException("Callback Registration failed");
View Full Code Here

       try {
           HttpClient client = new HttpClient();
           PostMethod method = new PostMethod(MessagingServiceMessagesURL);
           Base64 base64 = new Base64();
           String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
           method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
           method.setRequestEntity(new StringRequestEntity("Hello2 !", "text/plain", "UTF-8"));
           int status = client.executeMethod(method);
           if (HttpResponseCodes.SC_OK != status) {
               throw new RuntimeException("Messages can not be sent");
           }
View Full Code Here

   {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(ConsumerRegistrationURL);
      Base64 base64 = new Base64();
      String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
      method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
      method.addParameter(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
      int status = client.executeMethod(method);
      if (HttpResponseCodes.SC_OK != status) {
          throw new RuntimeException("Registration failed");
      }
View Full Code Here

   {
       HttpClient client = new HttpClient();
       PostMethod method = new PostMethod(ConsumerScopesRegistrationURL);
       Base64 base64 = new Base64();
       String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
       method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
       method.addParameter(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
       method.addParameter("xoauth_scope", scope);
       method.addParameter("xoauth_permission", "sendMessages");
       int status = client.executeMethod(method);
       if (HttpResponseCodes.SC_OK != status) {
View Full Code Here

   {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(MessagingServiceCallbackRegistrationURL);
      Base64 base64 = new Base64();
      String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
      method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
      method.addParameter("consumer_id", consumerKey);
      method.addParameter("consumer_secret", consumerSecret);
      method.addParameter("callback_uri", callback);
      int status = client.executeMethod(method);
      if (HttpResponseCodes.SC_OK != status) {
View Full Code Here

   {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(MessagingServiceMessagesURL);
      Base64 base64 = new Base64();
      String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
      method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
      method.setRequestEntity(new StringRequestEntity("Hello !", "text/plain", "UTF-8"));
      int status = client.executeMethod(method);
      if (HttpResponseCodes.SC_OK != status) {
          throw new RuntimeException("Messages can not be sent");
      }
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.