Hello there,

I've noticed (Restlet 2.0snapshot from 2010-02-19 IIRC) that there's
no @Head annotation to handle HEAD requests. The method annotated with
@Get is handling HEAD also. A priori this makes some sense because one
expects to get the same answer for HEAD and GET, except that HEAD has
just metadata (in the HTTP headers) while GET has both the metadata
and a body with the representation of the resource in question.

So far, so good.

This "no body in the response" almost mandates the usage of
EmptyRepresentation... except that it cannot have the other metadata
set properly.

Look at this example, code:

getLogger().info("-*-*-*-*-*-*-*-*-DBG: METADATA: " + cmd.toString());
Representation rep = new EmptyRepresentation();
rep.setModificationDate(cmd.getLastModif().getTime());
rep.setSize(cmd.getSize());
rep.setMediaType(new MediaType(cmd.getMimeType()));
return rep;

It basically creates an empty representation (no Content-Type header,
Length header fixed to 0) and then tries to set the "correct" metadata
(Content-Type, Length and Date are the ones I need properly set) by
issuing standard API calls as suggested by both the Restlet engine and
the docs at 
http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/130-restlet.html

However, this is not working, in the logs I get the correct metadata info:

*****************
INFO: -*-*-*-*-*-*-*-*-DBG: METADATA: { Last Modified on
java.util.GregorianCalendar[time=1266859161000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="America/Buenos_Aires",offset=-10800000,dstSavings=3600000,useDaylight=true,transitions=118,lastRule=java.util.SimpleTimeZone[id=America/Buenos_Aires,offset=-10800000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=9,startDay=15,startDayOfWeek=1,startTime=0,startTimeMode=0,endMode=3,endMonth=2,endDay=15,endDayOfWeek=1,endTime=0,endTimeMode=0]],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2010,MONTH=1,WEEK_OF_YEAR=9,WEEK_OF_MONTH=4,DAY_OF_MONTH=22,DAY_OF_YEAR=53,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=4,AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=19,SECOND=21,MILLISECOND=0,ZONE_OFFSET=-10800000,DST_OFFSET=3600000],
Type text/plain, Size 19 bytes, HEAD rev is 1.1 }
*****************

But in the response I don't get the correct metadata info, and just
get the ones corresponding to EmptyRepresentation (which is not what
should be happening...):

*****************
HTTP/1.1 200 The request has succeeded

Content-Length: 0

Connection: close

Date: Mon, 22 Feb 2010 16:00:13 GMT

Accept-Ranges: bytes

Server: Restlet-Framework/2.0snapshot

*****************

Using Restlet 2.0snapshot from 2010-02-19 IIRC (not the latest, but
the one before, or two before)

Needless to say that if I try to set the HTTP headers on purpose with
the correct values, Restlet correctly barks:

*****************
Feb 22, 2010 3:19:21 PM org.restlet.engine.http.header.HeaderUtils
addExtensionHeaders
WARNING: Addition of the standard header "Content-Type" is not
allowed. Please use the equivalent property in the Restlet API.
Feb 22, 2010 3:19:21 PM org.restlet.engine.http.header.HeaderUtils
addExtensionHeaders
WARNING: Addition of the standard header "Content-Length" is not
allowed. Please use the equivalent property in the Restlet API.
*****************

Thanks in advance...

-- 
Fabián Mandelbaum
IS Engineer

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2450556

Reply via email to