Package org.apache.http.client.methods

Examples of org.apache.http.client.methods.HttpRequestBase.addHeader()


        }

        // Add the authentication token to the request
        if (authnToken != null) {
            if (type.equals(AuthTokenType.API)) {
                request.addHeader(Constants.NODEABLE_AUTH_TOKEN, authnToken);
            } else if (type.equals(AuthTokenType.GATEWAY)) {
                request.addHeader(Constants.NODEABLE_API_KEY, authnToken);
            } else {
                throw new Exception("Unsupported Type of  " + type + " for authToken " + authnToken);
            }
View Full Code Here


        // Add the authentication token to the request
        if (authnToken != null) {
            if (type.equals(AuthTokenType.API)) {
                request.addHeader(Constants.NODEABLE_AUTH_TOKEN, authnToken);
            } else if (type.equals(AuthTokenType.GATEWAY)) {
                request.addHeader(Constants.NODEABLE_API_KEY, authnToken);
            } else {
                throw new Exception("Unsupported Type of  " + type + " for authToken " + authnToken);
            }

        }
View Full Code Here

        }

        /* Add request headers if need be */
        if (requestHeaders != null) {
            for (Header header : requestHeaders) {
                httpMethod.addHeader(header);
            }
        }

        LOGGER.debug("Making HTTP request as " + (username != null ? username : "anonymous") + ": " + method +
                " - " + url);
View Full Code Here

        Headers headers = method.getAnnotation(Headers.class);
        if (headers != null) {
            logger.debug("found @Headers");
            for (Header header : headers.headers()) {
                logger.debug("add header => name[" + header.key() + "] value[" + header.value() + "]");
                httpMethod.addHeader(header.key(), header.value());
            }
        }

        Validation validation = method.getAnnotation(Validation.class);
        if (validation != null) {
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)) {
                httpRequest.addHeader(entry.getKey(), headerValue);
            }
        }

        // lets store the result in the output message.
        HttpResponse httpResponse = null;
View Full Code Here

            exchange.getIn().getHeaders().remove("host");
        }
        HttpRequestBase httpRequest = createMethod(exchange);
        if (getEndpoint().isAuthenticationPreemptive()) {
            Credentials creds = ((DefaultHttpClient) httpClient).getCredentialsProvider().getCredentials(AuthScope.ANY);
            httpRequest.addHeader(new BasicScheme().authenticate(creds, httpRequest));
        }
        Message in = exchange.getIn();
        String httpProtocolVersion = in.getHeader(Exchange.HTTP_PROTOCOL_VERSION, String.class);
        if (httpProtocolVersion != null) {
            // set the HTTP protocol version
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);
                    httpRequest.addHeader(key, s);
                }
            }
        }

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

            httpMethod == ODataHttpMethod.DELETE ? new HttpDelete() :
                httpMethod == ODataHttpMethod.POST ? new HttpPost() :
                    httpMethod == ODataHttpMethod.PUT ? new HttpPut() : new HttpPatch();
    request.setURI(URI.create(getEndpoint() + uri));
    if (additionalHeader != null) {
      request.addHeader(additionalHeader, additionalHeaderValue);
    }
    if (requestBody != null) {
      ((HttpEntityEnclosingRequest) request).setEntity(new StringEntity(requestBody));
      request.setHeader(HttpHeaders.CONTENT_TYPE, requestContentType);
    }
View Full Code Here

      // common request parts
      Set<Entry<String, String>> entries = headers.entrySet();

      for (Entry<String, String> entry : entries) {
        request.addHeader(entry.getKey(), entry.getValue());
      }

      return request;
    }
View Full Code Here

          throw new ApplicationException("mixing httpparam  type file/formfield and body/XML is not allowed");
     
        if(!hasContentType) {
          if(isBinary) {
            if(hasBody) req.addHeader("Content-type", "application/octet-stream");
            else req.addHeader("Content-type", "application/x-www-form-urlencoded; charset="+charset);
          }
          else {
            if(hasBody)
              req.addHeader("Content-type", "text/html; charset="+charset );
          }
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.