Package org.apache.commons.httpclient

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


             
              if(param.getName().equalsIgnoreCase("Accept-Encoding")) {
                acceptEncoding.append(headerValue(param.getValueAsString()));
                acceptEncoding.append(", ");
              }
              else httpMethod.addRequestHeader(param.getName(),headerValue(param.getValueAsString()));
            }
    // Cookie
      else if(type.equals("cookie")) {
        Cookie c=toCookie(_url.getHost(),param.getName(),param.getValueAsString(),_charset);
        c.setPath("/");
View Full Code Here


      }
    // XML
      else if(type.equals("xml")) {
        hasBody=true;
        hasContentType=true;
        httpMethod.addRequestHeader("Content-type", "text/xml; charset="+http.charset);
          //post.setRequestBody(new NameValuePair [] {new NameValuePair(translateEncoding(param.getName(), charset),translateEncoding(param.getValue(), charset))});
        if(eem==null)throw new ApplicationException("type xml is only supported for type post and put");
          eem.setRequestBody(param.getValueAsString());
      }
    // Body
View Full Code Here

    if(hasBody && hasForm)
      throw new ApplicationException("mixing httpparam  type file/formfield and body/XML is not allowed");
 
    if(!hasContentType) {
      if(isBinary) {
        if(hasBody) httpMethod.addRequestHeader("Content-type", "application/octet-stream");
        else httpMethod.addRequestHeader("Content-type", "application/x-www-form-urlencoded; charset="+http.charset);
      }
      else {
        if(hasBody)
          httpMethod.addRequestHeader("Content-type", "text/html; charset="+http.charset );
View Full Code Here

      throw new ApplicationException("mixing httpparam  type file/formfield and body/XML is not allowed");
 
    if(!hasContentType) {
      if(isBinary) {
        if(hasBody) httpMethod.addRequestHeader("Content-type", "application/octet-stream");
        else httpMethod.addRequestHeader("Content-type", "application/x-www-form-urlencoded; charset="+http.charset);
      }
      else {
        if(hasBody)
          httpMethod.addRequestHeader("Content-type", "text/html; charset="+http.charset );
      }
View Full Code Here

        if(hasBody) httpMethod.addRequestHeader("Content-type", "application/octet-stream");
        else httpMethod.addRequestHeader("Content-type", "application/x-www-form-urlencoded; charset="+http.charset);
      }
      else {
        if(hasBody)
          httpMethod.addRequestHeader("Content-type", "text/html; charset="+http.charset );
      }
    }
   
   
    // set User Agent
View Full Code Here

        case OPTIONS: httpMethod = new OptionsMethod(uri); break;
        case TRACE:   httpMethod = new TraceMethod(uri); break;
        default:      httpMethod = getMethod(new ExtensionMethod(method,uri), entity);
      }
      if (actual != null) {
        httpMethod.addRequestHeader("X-HTTP-Method-Override", actual.name());
      }
      initHeaders(options, httpMethod);
     
      // by default use expect-continue is enabled on the client
      // only disable if explicitly disabled
View Full Code Here

    //
    // Make another proxied request, this time send the cookie
    //
    String cookieurl = PROXY_URL+"?instanceid_key="+instance_id_key+"&url=http://localhost:9000";
    req = new GetMethod(cookieurl);
    req.addRequestHeader("Cookie", "test=wookie");
    client.executeMethod(req);
    code = req.getStatusCode();
    header = req.getResponseHeader("GOT-COOKIE").getValue();

    req.releaseConnection();
View Full Code Here

        // propagate headers as HTTP headers
        for (String headerName : in.getHeaders().keySet()) {
            String headerValue = in.getHeader(headerName, String.class);
            if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
                method.addRequestHeader(headerName, headerValue);
            }
        }

        // lets store the result in the output message.
        try {
View Full Code Here

                // add the value(s) as a http request header
                if (values.size() > 0) {
                    // use the default toString of a ArrayList to create in the form [xxx, yyy]
                    // if multi valued, for a single value, then just output the value as is
                    String s =  values.size() > 1 ? values.toString() : values.get(0);
                    method.addRequestHeader(key, s);
                }
            }
        }

        // lets store the result in the output message.
View Full Code Here

        } else {
            GetMethod httpget = new GetMethod(url.getPath());
            method = httpget;
        }
        if (!keepAlive) {
            method.addRequestHeader("Connection", "close");
        }
       
        // Prepare request executor
        HttpClient executor = createRequestExecutor();
        BenchmarkWorker worker = new BenchmarkWorker(executor, verbosity);
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.