Hi Jean-Philippe, It doesn't, and the main problem is that you need to consume the stream for the digest to be computed. If you want to do it in a filter, you have to store whatever your read and then put the data back into the representation.
I've just tried with a simple example and a some text, but I think there is a bug (*). Assuming that bug is fixed, you could have something like that: public class DigesterFilterDemo extends Filter { @Override protected int doHandle(Request request, Response response) { Representation entity = request.getEntity(); if ((entity != null) && (entity.getDigest() != null)) { try { DigesterRepresentation digesterRepresentation = new DigesterRepresentation( entity); String text = digesterRepresentation.getText(); if (!digesterRepresentation.checkDigest()) { response.setStatus(Status.CLIENT_ERROR_BAD_REQUEST); return Filter.STOP; } request.setEntity(new StringRepresentation(text, request .getEntity().getMediaType())); } catch (NoSuchAlgorithmException e) { response.setStatus(Status.SERVER_ERROR_INTERNAL, e); return Filter.STOP; } catch (IOException e) { response.setStatus(Status.SERVER_ERROR_INTERNAL, e); return Filter.STOP; } } return super.doHandle(request, response); } } This being said, it's probably better to check the digest in the resource that's consuming the entity, since this temporary storage into a 'text' variable is not suitable for all types of entities (and you might need a large buffer). The checkDigest() will only work once you've exhausted the stream (of course, you could use exhaust(), but that discards the content.) (*) Coming back to what I think is a bug: DigesterRepresentation overrides getStream() to make it compute the digest as the stream is being consumed. However, if you use DigesterRepresentation.getText(), this uses WrapperRepresentation.getWrappedRepresentation().getText(), which then uses the wrapped representation's getStream(), not the DigesterRepresentation's, so the digest isn't being computed when the stream (from the wrapped representation) is being read. Removing WrappedRepresentation.getText() fixes the problem: then getText() uses write() (the default), which in turn uses getStream() correctly, as overridden by DigesterRepresentation. Best wishes, Bruno. On 19/05/10 19:04, Jean-Philippe Steinmetz wrote: > Hello, > > I have a simple question. Does the restlet server connector verify > Content-MD5 headers by default? If not, is there a setting or filter I > can enable to make sure that it does? > > Jean-Philippe ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2611379