code: public static void setContent(final HttpRequestBase req,
                                  final byte[] content,
                                  final String contentType) throws HttpException {
      if (content == null) {
        return;
      }
  
      if (!(req instanceof HttpEntityEnclosingRequestBase)) {
        throw new HttpException("Invalid operation for method " +
                                        req.getMethod());
      }
  
      final HttpEntityEnclosingRequestBase eem = (HttpEntityEnclosingRequestBase)req;
  
      final ByteArrayEntity entity = new ByteArrayEntity(content);
      entity.setContentType(contentType);
      eem.setEntity(entity);
    }
docs: Send content
  
  @param content the content as bytes
  @param contentType its type
  @throws HttpException if not entity enclosing request