Package org.apache.commons.httpclient

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


        // 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)) {
                method.addRequestHeader(headerName, headerValue);
            }
        }

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


       
        //TODO support other methods
        HttpMethod method = new GetMethod(url.getPathQuery());
        Header[] headers = conn.getHeaders();
        for (int i=0; i<headers.length; i++) {
            method.addRequestHeader(headers[i]);
        }
        if (method instanceof EntityEnclosingMethod) {
            EntityEnclosingMethod emethod = (EntityEnclosingMethod) method;
            emethod.setRequestBody(conn.getInputStream());
        }
View Full Code Here

        HttpBinding binding = ((HttpEndpoint)getEndpoint()).getBinding();
        // propagate headers as HTTP headers
        for (String headerName : in.getHeaders().keySet()) {
            String headerValue = in.getHeader(headerName, String.class);
            if (binding.shouldHeaderBePropagated(headerName, headerValue)) {
                method.addRequestHeader(headerName, headerValue);
            }
        }

        // lets store the result in the output message.
        Message out = exchange.getOut(true);
View Full Code Here

  public Response execute(Command command) throws Exception {
    CommandInfo info = nameToUrl.get(command.getName());
    HttpMethod httpMethod = info.getMethod(remotePath, command);

    httpMethod.addRequestHeader("Accept", "application/json, image/png");

    String payload = new BeanToJsonConverter().convert(command.getParameters());

    if (httpMethod instanceof PostMethod) {
      ((PostMethod) httpMethod)
View Full Code Here

    // TODO: SimonStewart: 2008-04-25: This is really shabby
    if (isRedirect(httpMethod)) {
      Header newLocation = httpMethod.getResponseHeader("location");
      httpMethod = new GetMethod(newLocation.getValue());
      httpMethod.setFollowRedirects(true);
      httpMethod.addRequestHeader("Accept", "application/json, image/png");
      client.executeMethod(httpMethod);
    }

    return createResponse(httpMethod);
  }
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

            // and PUT method classes (we already have APPEND and COPY methods) and implement a getRequestHeader that returns the specific
            // string '100-continue' for an Expect lookup if the method has an Expect: 100 header on it.
            // Anyway, the ExpectContinueMethod code doesn't set the Expect header if there already is an Expect header, so add this header back in
            // specifically so that it will be available to the subtypes if we actually do the subtyping. Yegads.
            // Oh, yeah. Case matters to HttpClient for the Expect header name.
            resMethod.addRequestHeader(new Header("Expect", "100-continue"));
        }

        return resMethod;       
    }
View Full Code Here

        // propagate headers as HTTP headers
        for (Map.Entry<String, Object> entry : in.getHeaders().entrySet()) {
            String headerValue = in.getHeader(entry.getKey(), String.class);
            if (strategy != null && !strategy.applyFilterToCamelHeaders(entry.getKey(), headerValue, exchange)) {
                method.addRequestHeader(entry.getKey(), 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

                // 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

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.