Package org.apache.http.client.methods

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


            //Adding headers
            if (this.contentType == null){
                this.contentType = SynchronousRestClient.xmlContentType;
            }
            httpMethod.addHeader("Content-type", this.contentType);
            if (authorizationValue != null) {
                httpMethod.addHeader("Authorization", ApacheRestClient.authorizationValue);
            }

            //Executing
View Full Code Here


            if (this.contentType == null){
                this.contentType = SynchronousRestClient.xmlContentType;
            }
            httpMethod.addHeader("Content-type", this.contentType);
            if (authorizationValue != null) {
                httpMethod.addHeader("Authorization", ApacheRestClient.authorizationValue);
            }

            //Executing
            HttpResponse httpResponse = client.execute(httpMethod);
View Full Code Here

        httpMethod = new HttpHead(requestUri);
      } else if ("DELETE".equals(methodType)) {
        httpMethod = new HttpDelete(requestUri);
      }
      for (Map.Entry<String, List<String>> entry : request.getHeaders().entrySet()) {
        httpMethod.addHeader(entry.getKey(), Joiner.on(',').join(entry.getValue()));
      }

      // Disable following redirects.
      if (!request.getFollowRedirects()) {
        httpMethod.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
View Full Code Here

        httpMethod = new HttpHead(requestUri);
      } else if ("DELETE".equals(methodType)) {
        httpMethod = new HttpDelete(requestUri);
      }
      for (Map.Entry<String, List<String>> entry : request.getHeaders().entrySet()) {
        httpMethod.addHeader(entry.getKey(), StringUtils.join(entry.getValue(), ','));
      }

      if (!request.getFollowRedirects())
        httpMethod.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
View Full Code Here

      if (apacheRequest instanceof HttpEntityEnclosingRequest) {
         if (payload != null) {
            addEntityForContent(HttpEntityEnclosingRequest.class.cast(apacheRequest), payload);
         }
      } else {
         apacheRequest.addHeader(HttpHeaders.CONTENT_LENGTH, "0");
      }

      for (Map.Entry<String, String> entry : request.getHeaders().entries()) {
         String header = entry.getKey();
         // apache automatically tries to add content length header
View Full Code Here

      for (Map.Entry<String, String> entry : request.getHeaders().entries()) {
         String header = entry.getKey();
         // apache automatically tries to add content length header
         if (!header.equals(HttpHeaders.CONTENT_LENGTH))
            apacheRequest.addHeader(header, entry.getValue());
      }
      apacheRequest.addHeader(HttpHeaders.USER_AGENT, USER_AGENT);
      return apacheRequest;
   }
View Full Code Here

         String header = entry.getKey();
         // apache automatically tries to add content length header
         if (!header.equals(HttpHeaders.CONTENT_LENGTH))
            apacheRequest.addHeader(header, entry.getValue());
      }
      apacheRequest.addHeader(HttpHeaders.USER_AGENT, USER_AGENT);
      return apacheRequest;
   }

   public void addEntityForContent(HttpEntityEnclosingRequest apacheRequest, Payload payload) {
      payload = payload instanceof DelegatingPayload ? DelegatingPayload.class.cast(payload).getDelegate() : payload;
View Full Code Here

   @Override
   protected HttpUriRequest convert(HttpRequest request) throws IOException {
      HttpUriRequest returnVal = apacheHCUtils.convertToApacheRequest(request);
      if (request.getPayload() != null && request.getPayload().getContentMetadata().getContentMD5() != null){
         String md5 = base64().encode(asByteSource(request.getPayload().getInput()).hash(md5()).asBytes());
         returnVal.addHeader("Content-MD5", md5);
      }

      return returnVal;
   }
View Full Code Here

  private boolean remoteUserExists(String[] user, String url) throws URISyntaxException,
      ClientProtocolException, IOException, AuthenticationException {
    UsernamePasswordCredentials creds = new UsernamePasswordCredentials(user[0], user[1]);
    DefaultHttpClient authorizedClient = new DefaultHttpClient();
    HttpUriRequest request = new HttpGet(url);
    request.addHeader(new BasicScheme().authenticate(creds, request));
    HttpResponse response = authorizedClient.execute(request);
    EntityUtils.consume(response.getEntity());
    int code = response.getStatusLine().getStatusCode();
    return code != HttpURLConnection.HTTP_UNAUTHORIZED;
  }
View Full Code Here

  private boolean logsAvailable(String url) throws URISyntaxException, ClientProtocolException,
      IOException, AuthenticationException {
    UsernamePasswordCredentials creds = new UsernamePasswordCredentials("anonymous", "");
    DefaultHttpClient authorizedClient = new DefaultHttpClient();
    HttpUriRequest request = new HttpGet(url);
    request.addHeader(new BasicScheme().authenticate(creds, request));
    HttpResponse response = authorizedClient.execute(request);
    String body = EntityUtils.toString(response.getEntity());
    return body.contains("*INFO*") || body.contains("*WARN*");
  }

 
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.