Package org.apache.commons.httpclient

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


                    List valueList = (List)value;
                    for (Iterator iterator = valueList.iterator(); iterator.hasNext();)
                    {
                        Object currentValue = (Object)iterator.next();
                        if (currentValue == null)
                            httpMethod.addRequestHeader(name, "");
                        else
                            httpMethod.addRequestHeader(name, (String)currentValue);
                    }
                }
                else if (value.getClass().isArray())
View Full Code Here


                    {
                        Object currentValue = (Object)iterator.next();
                        if (currentValue == null)
                            httpMethod.addRequestHeader(name, "");
                        else
                            httpMethod.addRequestHeader(name, (String)currentValue);
                    }
                }
                else if (value.getClass().isArray())
                {
                    Object[] valueArray = (Object[])value;
View Full Code Here

                    Object[] valueArray = (Object[])value;
                    for (int i = 0; i < valueArray.length; i++)
                    {
                        Object currentValue = valueArray[i];
                        if (currentValue == null)
                            httpMethod.addRequestHeader(name, "");
                        else
                            httpMethod.addRequestHeader(name, (String)currentValue);
                    }
                }
            }
View Full Code Here

                    {
                        Object currentValue = valueArray[i];
                        if (currentValue == null)
                            httpMethod.addRequestHeader(name, "");
                        else
                            httpMethod.addRequestHeader(name, (String)currentValue);
                    }
                }
            }
        }
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);
View Full Code Here

            int statusCode = client.executeMethod(httpMethod);

            // We've finished with the request, so we can add the LocalAddress to it for display
            final InetAddress localAddr = client.getHostConfiguration().getLocalAddress();
            if (localAddr != null) {
                httpMethod.addRequestHeader(HEADER_LOCAL_ADDRESS, localAddr.toString());
            }
            // Needs to be done after execute to pick up all the headers
            res.setRequestHeaders(getConnectionHeaders(httpMethod));

            // Request sent. Now get the response:
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
      {
         System.err.println("Connecting to: "+url);
         String userInfo = url.getUserInfo();
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

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.