Package org.apache.http.client.methods

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


        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(), Joiner.on(',').join(entry.getValue()));
      }

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

    path = sb.toString();

    HttpUriRequest request = buildMethod(method, path, params);

    request.addHeader(new BasicHeader("X-Twilio-Client", "java-" + VERSION));
    request.addHeader(new BasicHeader("User-Agent", "twilio-java/" + VERSION));
    request.addHeader(new BasicHeader("Accept", "application/json"));
    request.addHeader(new BasicHeader("Accept-Charset", "utf-8"));

    if (httpclient instanceof DefaultHttpClient) { // as DefaultHttpClient class has final method, I need httpClient to be a plain interface to be able to mock it
View Full Code Here

    path = sb.toString();

    HttpUriRequest request = buildMethod(method, path, params);

    request.addHeader(new BasicHeader("X-Twilio-Client", "java-" + VERSION));
    request.addHeader(new BasicHeader("User-Agent", "twilio-java/" + VERSION));
    request.addHeader(new BasicHeader("Accept", "application/json"));
    request.addHeader(new BasicHeader("Accept-Charset", "utf-8"));

    if (httpclient instanceof DefaultHttpClient) { // as DefaultHttpClient class has final method, I need httpClient to be a plain interface to be able to mock it
      ((DefaultHttpClient) httpclient).getCredentialsProvider()
View Full Code Here

    HttpUriRequest request = buildMethod(method, path, params);

    request.addHeader(new BasicHeader("X-Twilio-Client", "java-" + VERSION));
    request.addHeader(new BasicHeader("User-Agent", "twilio-java/" + VERSION));
    request.addHeader(new BasicHeader("Accept", "application/json"));
    request.addHeader(new BasicHeader("Accept-Charset", "utf-8"));

    if (httpclient instanceof DefaultHttpClient) { // as DefaultHttpClient class has final method, I need httpClient to be a plain interface to be able to mock it
      ((DefaultHttpClient) httpclient).getCredentialsProvider()
                                      .setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
View Full Code Here

    HttpUriRequest request = buildMethod(method, path, params);

    request.addHeader(new BasicHeader("X-Twilio-Client", "java-" + VERSION));
    request.addHeader(new BasicHeader("User-Agent", "twilio-java/" + VERSION));
    request.addHeader(new BasicHeader("Accept", "application/json"));
    request.addHeader(new BasicHeader("Accept-Charset", "utf-8"));

    if (httpclient instanceof DefaultHttpClient) { // as DefaultHttpClient class has final method, I need httpClient to be a plain interface to be able to mock it
      ((DefaultHttpClient) httpclient).getCredentialsProvider()
                                      .setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
                                                      new UsernamePasswordCredentials(accountSid, authToken));
View Full Code Here

        }
       
        HttpUriRequest httpUriRequest = request.getHttpUriRequest();
       
        if (!httpUriRequest.containsHeader(USER_AGENT)) {
            httpUriRequest.addHeader(USER_AGENT, DEFAULT_USER_AGENT);
        }
       
        HttpResponse response;
       
        try {
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

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.