public static void main(String[] args) throws Exception { ClientResource resource = new ClientResource("http://localhost:8111/"); // The Digester helps computing the digest while reading or writing the // representation's content. DigesterRepresentation rep = new DigesterRepresentation(resource.get()); rep.write(System.out); if (rep.checkDigest()) { System.out.println("\nContent checked."); } else { System.out.println("\nContent not checked."); } }
@Get public Representation represent() throws Exception { // Wraps the StringRepresentation DigesterRepresentation result = new DigesterRepresentation( new StringRepresentation("hello, world")); result.exhaust(); // Compute representation's digest. result.setDigest(result.computeDigest()); return result; } }