Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpMethodBase.addRequestHeader()


   {
      HttpClient httpConn = new HttpClient();
      HttpMethodBase request = createMethod(url, type);
      int hdrCount = hdrs != null ? hdrs.length : 0;
      for(int n = 0; n < hdrCount; n ++)
         request.addRequestHeader(hdrs[n]);
      try
      {
         log.debug("Connecting to: "+url);
         String userInfo = url.getUserInfo();
         if( userInfo != null )
View Full Code Here


   {
      HttpClient httpConn = new HttpClient();
      HttpMethodBase request = createMethod(url, type);
      int hdrCount = hdrs != null ? hdrs.length : 0;
      for(int n = 0; n < hdrCount; n ++)
         request.addRequestHeader(hdrs[n]);
      try
      {
         log.debug("Connecting to: "+url);
         String userInfo = url.getUserInfo();
         if( userInfo != null )
View Full Code Here

      HttpClient httpConn = new HttpClient();
      HttpMethodBase request = createMethod(url, GET);

      int hdrCount = null != null ? ((Header[]) null).length : 0;
      for(int n = 0; n < hdrCount; n ++)
         request.addRequestHeader(((Header[]) null)[n]);
      try
      {
         log.info("Connecting to: "+ url);
         String userInfo = url.getUserInfo();
View Full Code Here

      HttpClient httpConn = new HttpClient();
      HttpMethodBase request = createMethod(url, type);

      int hdrCount = null != null ? ((Header[]) null).length : 0;
      for(int n = 0; n < hdrCount; n ++)
         request.addRequestHeader(((Header[]) null)[n]);
      try
      {
         log.info("Connecting to: "+ url);
         String userInfo = url.getUserInfo();
View Full Code Here

      String ticket = "";
      HttpClient client = new HttpClient();
        HttpMethodBase httpMethod = null;
        httpMethod = new PostMethod();
        //String useragentProperty = request.getProperty("User-Agent");
        httpMethod.addRequestHeader( "User-Agent", "Firefox" );
        httpMethod.setPath(url);
        try
        {
            client.executeMethod(httpMethod);
            int responseCode  = httpMethod.getStatusCode();
View Full Code Here

        /* Set content type and encoding */
        if (method.getRequestHeader("Content-Type") == null) {
            log.debug("Setting content-type to application/x-www-form-urlencoded; " +
                "charset=" + DEFAULT_ENCODING.toLowerCase());
            method.addRequestHeader("Content-Type",
                    "application/x-www-form-urlencoded; " +
                    "charset=" + DEFAULT_ENCODING.toLowerCase());
        } else {
            log.debug("Not overwriting Content-Type; already set to: " + method.getRequestHeader("Content-Type"));
        }
View Full Code Here

         */
        String hostHeader = endpoint.getHost();
        if (HttpUtils.isUsingNonDefaultPort(endpoint)) {
            hostHeader += ":" + endpoint.getPort();
        }
        method.addRequestHeader("Host", hostHeader);

        // When we release connections, the connection manager leaves them
        // open so they can be reused.  We want to close out any idle
        // connections so that they don't sit around in CLOSE_WAIT.
        httpClient.getHttpConnectionManager().closeIdleConnections(1000 * 30);
 
View Full Code Here

        }

        // No matter what type of HTTP method we're creating, we need to copy
        // all the headers from the request.
        for (Entry<String, String> entry : request.getHeaders().entrySet()) {
            method.addRequestHeader(entry.getKey(), entry.getValue());
        }

        return method;
    }
View Full Code Here

    Header head = get.getResponseHeader("Last-Modified");
    assertNull("We got a Last-Modified header", head);

    // If-Modified-Since tests
    get = getSelectMethod(method);
    get.addRequestHeader("If-Modified-Since", DateUtil.formatDate(new Date()));

    getClient().executeMethod(get);
    checkResponseBody(method, get);
    assertEquals("Expected 200 with If-Modified-Since header. We should never get a 304 here", 200,
        get.getStatusCode());
View Full Code Here

    checkResponseBody(method, get);
    assertEquals("Expected 200 with If-Modified-Since header. We should never get a 304 here", 200,
        get.getStatusCode());

    get = getSelectMethod(method);
    get.addRequestHeader("If-Modified-Since", DateUtil.formatDate(new Date(System.currentTimeMillis()-10000)));
    getClient().executeMethod(get);
    checkResponseBody(method, get);
    assertEquals("Expected 200 with If-Modified-Since header. We should never get a 304 here",
        200, get.getStatusCode());
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.