All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.resteasy.util.HttpClient4xUtils Maven / Gradle / Ivy

There is a newer version: 4.0.0.Beta5
Show newest version
package org.jboss.resteasy.util;

import org.apache.http.HttpResponse;
import org.apache.http.util.EntityUtils;
import org.jboss.resteasy.resteasy_jaxrs.i18n.LogMessages;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

/**
 * HttpClient4xUtils provides utility methods useful for changes
 * necessitated by switching from HttpClient 3.x to HttpClient 4.x.
 *
 * @author Ron Sigal
 * @version $Revision: 1 $
 */
public class HttpClient4xUtils
{

   public static void consumeEntity(HttpResponse response)
   {
      try
      {
         if (response != null)
             EntityUtils.consume(response.getEntity());
      } catch (IOException e)
      {
         LogMessages.LOGGER.unableToCloseEntityStream(e);
      }
   }

   public static String updateQuery(String uriString, String query)
   {
      try
      {
         URI uri = new URI(uriString);
         return new URI(uri.getScheme(), uri.getAuthority(), uri.getPath(), query, uri.getFragment()).toString();
      } catch (URISyntaxException e)
      {
         throw new RuntimeException(e);
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy