List of usage examples for org.apache.http.util CharsetUtils lookup
public static Charset lookup(String str)
From source file:com.flipkart.bifrost.http.HttpCallCommand.java
private HttpUriRequest generateRequestObject() throws BifrostException { try {//from w w w . ja va2 s. c o m switch (requestType) { case HTTP_GET: return new HttpGet(url); case HTTP_POST: HttpPost post = new HttpPost(url); post.setEntity(new ByteArrayEntity(mapper.writeValueAsBytes(request), ContentType.create(contentType, CharsetUtils.lookup("utf-8")))); return post; case HTTP_PUT: HttpPut put = new HttpPut(url); put.setEntity(new ByteArrayEntity(mapper.writeValueAsBytes(request), ContentType.create(contentType, CharsetUtils.lookup("utf-8")))); return put; case HTTP_DELETE: return new HttpDelete(url); } } catch (JsonProcessingException e) { throw new BifrostException(BifrostException.ErrorCode.SERIALIZATION_ERROR, "Could not serialize request body"); } throw new BifrostException(BifrostException.ErrorCode.UNSUPPORTED_REQUEST_TYPE, String.format("Request type %s is not supported", requestType.name())); }