Hi Peter, This case is handled a bit differently because we do want to return the representation's metadata to the client in this case. Currently, the Response's entity must be an instance of Representation and not a simple Variant.
Note that the HTTP connectors do recognize the 204 status and won't send the Representation's content, only the metadata, but it is true that Resource#getRepresentation(Variant) will be invoked. Do you have use cases that would help me feel how important it is to optimize this? As a workaround to returning full representations, you could write an EmptyRepresentation that would be a Variant with no content. Maybe that would be a useful addition to the API. Best regards, Jerome > -----Message d'origine----- > De : news [mailto:[EMAIL PROTECTED] De la part de Peter Lacey > Envoyé : mercredi 20 juin 2007 18:26 > À : [email protected] > Objet : Re: Conditional GETs? > > Jerome, > > Here's another variant of the same issue. If the server > wants to return > a 204 (No Content), then #getRepresentation() is still > called. Does it > make sense to optimize this out of the way so that the status > can be set > in the constructor and Restlet takes care of doing the right > thing, or > should the status be set by the developer in #getRepresentation() and > null returned? > > Pete > > Jerome Louvel wrote: > > Hi all, > > > > This RFE is now fixed in SVN trunk and will be testable in > the upcoming 1.1 > > snapshot. Great optimization, thanks Stian for the idea. > > > > Best regards, > > Jerome > > > >> -----Message d'origine----- > >> De : Jerome Louvel [mailto:[EMAIL PROTECTED] > >> Envoyé : mardi 12 juin 2007 08:55 > >> À : [email protected] > >> Objet : Re: Conditional GETs? > >> > >> Hi Adam, > >> > >> There is already a "tag" property on the Variant class > that you can > >> already use. In 1.1, we will simply use this property > earlier in the > >> algorithm to not call getRepresentation(Variant) when not > necessary. > >> > >> Best regards, > >> Jerome > >> > >> > >> Adam Taft a écrit : > >>> By the way, I love the suggestion. > >>> > >>> Can't you add getTag() (or some method) sooner rather than > >> later? The > >>> default implementation would simply return NULL which would > >> then force > >>> the algorithm to call getRepresentation() just like it > >> currently does. > >>> There should be no consequence of this in 1.0.x code? > >>> > >>> Just curious. > >>> > >>> Adam > >>> > >>> > >>> Jerome Louvel wrote: > >>>> Hi Stian, > >>>> > >>>> We haven't forgotten about your suggestion, just dealing > >> with a long > >>>> email > >>>> backlog :) > >>>> It is perfectly possible to optimize the internal > algorithm so that > >>>> getRepresentation(Variant) is never called when the > variant's tag > >>>> matches > >>>> the one provided by the client. > >>>> > >>>> I've entered a RFE to keep track of it: > >>>> http://restlet.tigris.org/issues/show_bug.cgi?id=319 > >>>> > >>>> As it changes the observed behavior a bit, it should only go in > >>>> Restlet 1.1, > >>>> IMHO. > >>>> > >>>> Best regards, > >>>> Jerome > >>>>> -----Message d'origine----- > >>>>> De : Stian Soiland [mailto:[EMAIL PROTECTED] Envoyé > >> : mercredi > >>>>> 6 juin 2007 11:23 > >>>>> À : [email protected] > >>>>> Objet : Re: Conditional GETs? > >>>>> > >>>>> > >>>>> On 4 Jun 2007, at 15:53, Peter Lacey wrote: > >>>>> > >>>>>> public Representation getRepresentation(Variant variant) { > >>>>>> Representation result = null; > >>>>>> > >>>>>> if > >> (variant.getMediaType().equals(MediaType.APPLICATION_XML)) { > >>>>>> > >>>>>> // create DOM > >>>>>> > >>>>>> result = new > >> DomRepresentation(MediaType.APPLICATION_XML, > >>>>>> doc); > >>>>>> result.setTag(new Tag([your etag], false)); > >>>>>> } > >>>>>> return result; > >>>>>> } > >>>>> It's really clever, except you still have to create that XML > >>>>> representation that never needs to be sent out. > >>>>> > >>>>> If there was some getTag() method or something you could > >> override > >>>>> this to check directly with the database on whatever > you need to > >>>>> calculate the tag, and hence getRepresentation() wouldn't > >> even need > >>>>> to be called. > >>>>> > >>>>> To support this I think some kind of getLastModified() > would also > >>>>> be cool. (I've made such a thing in my subclass of Resource) > >>>>> > >>>>> -- > >>>>> Stian Soiland, myGrid team > >>>>> School of Computer Science > >>>>> The University of Manchester > >>>>> http://www.cs.man.ac.uk/~ssoiland/ > >>>>> > >

