private String createPostEntity(final Message message, final Marshaller marshaller) {
   try {
     final ByteArrayOutputStream os = new ByteArrayOutputStream();
     marshaller.marshall(os, message.getRequestBodyMap(), UTF8, true);
     return os.toString(UTF8);
   } catch (UnsupportedEncodingException e) {
     throw new IllegalStateException(e);
   }
 }
  private List<Header> constructRequestHeaders(
      final Message message, final String contentType, TimeConstraints timeConstraints) {

    final List<Header> result = new ArrayList<Header>();

    result.add(new BasicHeader(ACCEPT, contentType));
    if (gzipCompressionEnabled) {
      result.add(new BasicHeader(ACCEPT_ENCODING, "gzip"));
    }
    result.add(new BasicHeader(USER_AGENT, USER_AGENT_HEADER));

    if (timeConstraints.getTimeRemaining() != null) {
      result.add(
          new BasicHeader("X-RequestTimeout", String.valueOf(timeConstraints.getTimeRemaining())));
    }

    for (Map.Entry<String, Object> entry : message.getHeaderMap().entrySet()) {
      result.add(new BasicHeader(entry.getKey(), entry.getValue().toString()));
    }

    return result;
  }