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


      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

                }  
            }
        }
       
        // propagate User-Agent, so target site does not think we are a D.O.S. attack
        httpMethod.addRequestHeader( "User-Agent", useragentProperty );
       
        // BOZO - DON'T do this.   default policy seems to be more flexible!!!
        //httpMethod.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
       
        // ...ready to use!
View Full Code Here

                }  
            }
        }
       
        // propagate User-Agent, so target site does not think we are a D.O.S. attack
        httpMethod.addRequestHeader( "User-Agent", useragentProperty );
       
        // BOZO - DON'T do this.   default policy seems to be more flexible!!!
        //httpMethod.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
       
        // ...ready to use!
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

                    List valueList = (List) value;
                    for (Object currentValue : valueList)
                    {
                        if (currentValue == null)
                        {
                            httpMethod.addRequestHeader(name, "");
                        }
                        else
                        {
                            httpMethod.addRequestHeader(name, (String) currentValue);
                        }
View Full Code Here

                        {
                            httpMethod.addRequestHeader(name, "");
                        }
                        else
                        {
                            httpMethod.addRequestHeader(name, (String) currentValue);
                        }
                    }
                }
                else if (value.getClass().isArray())
                {
View Full Code Here

                    Object[] valueArray = (Object[]) value;
                    for (Object currentValue : valueArray)
                    {
                        if (currentValue == null)
                        {
                            httpMethod.addRequestHeader(name, "");
                        }
                        else
                        {
                            httpMethod.addRequestHeader(name, (String) currentValue);
                        }
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.