code: private byte[] getSerializedEntity(ClientRequest request) {
          final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
  
          try {
              // By using the RequestWriter parent class, we match the behavior of entity writing from
              // for example, com.sun.jersey.client.urlconnection.URLConnectionClientHandler.
              writeRequestEntity(request, new RequestEntityWriterListener() {
                  public void onRequestEntitySize(long size) throws IOException {
                  }
  
                  public OutputStream onGetOutputStream() throws IOException {
                      return outputStream;
                  }
              });
  
          } catch (IOException e) {
              throw new ClientHandlerException("Unable to serialize request entity", e);
          }
  
          return outputStream.toByteArray();
      }
docs: Get the serialized representation of the request entity. This is used when generating the client
  signature, because this is the representation that the server will receive and use when it generates
  the server-side signature to compare to the client-side signature.
  
  @see com.sun.jersey.client.urlconnection.URLConnectionClientHandler