|
Hello Richard, it seems that "Etag" is a response header, not a request header (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19). It is used in request headers: if-match, if-none-match, etc. However, you can use your own header as follow: *** Client side: Request request = new Request(Method.POST, "http://localhost:8080/tag-test"); request.getClientInfo().getAcceptedMediaTypes().add(new Preference<MediaType>(MediaType.APPLICATION_JSON)); request.setEntity("ssome text", MediaType.APPLICATION_JSON); request.getEntity().setTag(new Tag("tag text")); Form headers = new Form(); // Your own tag headers.add("x-tag","tag text"); request.getAttributes().put(HttpConstants.ATTRIBUTE_HEADERS, headers); client.handle(request); *** Server side: Series<Parameter> headers = (Series<Parameter>) getRequest().getAttributes().get(HttpConstants.ATTRIBUTE_HEADERS); if (headers != null) { System.out.println(headers.getFirstValue("x-tag")); } NB: there may be an issue with the case of the request headers (on server side, headers may be lowerized. I check it). Best regards, Thierry Boileau -- Restlet ~ Core developer ~ http://www.restlet.org Noelios Technologies ~ Co-founder ~ http://www.noelios.com Hi THE SHORT VERSION:I'm using version 1.1.1. I post an entity with an ETag using org.restlet.Client and get a null ETag in acceptRepresentation. This happens with Tomcat but not with the standalone Restlet test. I can't find any code that looks like it would handle the propagation of the tag. I've tried using a custom header as a workaround but that has no effect either. This is critical for my project. Please help THE LONG VERSION: I'm trying to test a resource that uses an ETag when accepting a representation. Using org.restlet.Client: Request request = new Request(Method.POST, "http://localhost:8080/tag-test"); request.getClientInfo().getAcceptedMediaTypes().add(new Preference<MediaType>(MediaType.APPLICATION_JSON)); request.setEntity("some text", MediaType.APPLICATION_JSON); request.getEntity().setTag(new Tag("tag text")); Client client = new Client(Protocol.HTTP); Response response = client.handle(request); When acceptRepresentation is called, there is no sign of the ETag: public void acceptRepresentation(Representation entity) throws ResourceException { Tag tag = entity.getTag(); // turns up null This problem manifests when deploying on Tomcat-5.5.27 but not when deployed in standalone mode. This seems identical to the problem I reported earlier today (http://restlet.tigris.org/servlets/ReadMsg?list=discuss&msgNo=6852). I can't find any code that looks like it would propagate the etag. Specifically: 1. There does not appear to be any code that calls Representation.setTag. Since Tomcat will read the entity from a stream, the tag must be reconstituted in some way. I'd expect either Representation to be serializable (it's not) or something to explicitly call Representation.setTag (nothing does, as far as I can tell) 2. There seem to be 3 references to HttpConstants.ETAG, but as far as I can make out these all operate on the Response object: HttpConverter.addAdditionalHeaders (line 102, revision 3692) - modifies response HttpServerConverter.addEntityHeaders (line 133, revision 2965) - modifies response HttpClientCall.copyResponseEntityHeaders (line 143, revision 3882) - not called but I'm guessing modifies response Is there something wrong with my understanding of ETags or how they are set/read in Restlet? Can anyone point me to the class that should be handling this? I've also tried setting a custom header on the request as a workaround: request.getAttributes().put("my-custom-tag", "tag value") This doesn't seem to propagate either. Either I need sleep or there is a general mechanism that is broken. Regards Richard Hoberman |
- [Tomcat] ETag dropped between Client and acceptRepresenta... Richard Hoberman
- Re: [Tomcat] ETag dropped between Client and accep... Thierry Boileau
- Re: [Tomcat] ETag dropped between Client and a... Richard Hoberman
- Re: [Tomcat] ETag dropped between Client and accep... Richard Hoberman

