Package org.apache.http.client.methods

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


    public static HttpUriRequest createRequest(String method, String url, final Object payload) {

        LOG.debug("{} {}", method, url);

        HttpUriRequest httpUriRequest = METHODS.get(method.toUpperCase()).newMethod(url);
        httpUriRequest.addHeader("Accept", ContentType.APPLICATION_JSON.toString());

        if (payload != null) {
            try {

                // This cast will except if a body is given for non-HttpEntityEnclosingRequest types. Deal with it later.
View Full Code Here


    public static HttpUriRequest createRequest(String method, String url, final Object payload) {

        LOG.debug("{} {}", method, url);

        HttpUriRequest httpUriRequest = METHODS.get(method.toUpperCase()).newMethod(url);
        httpUriRequest.addHeader("Accept", ContentType.APPLICATION_JSON.toString());

        if (payload != null) {
            try {

                // This cast will except if a body is given for non-HttpEntityEnclosingRequest types. Deal with it later.
View Full Code Here

     * @return HttpUriRequest with header <code>Accept: application/json; charset=UTF-8</code>
     */
    public static HttpUriRequest createRequest(String method, String url, final Object payload) {

        HttpUriRequest httpUriRequest = METHODS.get(method.toUpperCase()).newMethod(url);
        httpUriRequest.addHeader("Accept", ContentType.APPLICATION_JSON.toString());

        if (payload != null) {
            try {

                // This cast will except if a body is given for non-HttpEntityEnclosingRequest types. Deal with it later.
View Full Code Here

  @Override
  public HttpUriRequest prepareRequest(String method, String uri, HttpEntity data) throws UnsupportedEncodingException {
    HttpUriRequest request = super.prepareRequest(method, uri, data);
    // TODO: Implement this if-modified-since
    //request.addHeader("If-Modified-Since", "");
    request.addHeader("Accept-Encoding", "gzip");
    return request;
  }
 
 
  public FeedServiceResponse parseFeeds(String[] feed_urls) throws ClientProtocolException, IOException
View Full Code Here

      Credentials creds = new UsernamePasswordCredentials(_username, _password);
      AuthScope scope = new AuthScope(request.getURI().getHost(), request.getURI().getPort());
      getCredentialsProvider().setCredentials(scope, creds);
    }
   
    request.addHeader("User-Agent", Global.USER_AGENT);
    return request;
  }
 
  protected String processResponse(HttpResponse response) throws IllegalStateException, IOException
  {
View Full Code Here

  }

  @Override
  protected HttpUriRequest prepareRequest(String method, String uri, HttpEntity data) throws UnsupportedEncodingException {
    HttpUriRequest request = super.prepareRequest(method, uri, data);
    request.addHeader("Accept", "application/json");
    return request;
  }

  @Override
  protected String processResponse(HttpResponse response) throws IllegalStateException, IOException {
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(ByteStreams2.hashAndClose(request.getPayload().openStream(), md5()).asBytes());
         returnVal.addHeader("Content-MD5", md5);
      }

      return returnVal;
   }
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.