Bob Harrod <rjharrod <at> hotmail.com> writes:

> 
> I'm trying to do something that seems very easy, but I cannot find any
> documentation on how to do this with Restlet.  I've created a few resources 
> and
> I want to change the content-type header to KML...  I'm not sure why this is 
> so
> difficult.  Any help would be greatly appreciated!
> 
> Essentially:
> 
>     public KMLResource( Context context, Request request, Response response ){
>       super( context, request, response );
>         response.setHeader( "Content-Type",
> "application/vnd.google-earth.kml+xml" );
> 
>     }
> 
>     @Override
>     public Representation getRepresentation( Variant variant ){
> 
>       Representation result = null;
> 
>         if( variant.getMediaType().equals(MediaType.APPLICATION_XML ) ) {
> 
>            result = new StringRepresentation( "....." );
>          return result;
>         }
>     }
> 
> 


I also tried the following, but received a WARNING: "Addition of the standard
header 'Content-Type' is not allowed.  Please us the Restlet API instead.".  The
result did not contain the correct header.

Map attributes = response.getAttributes();
Form headerForm = (Form)attributes.get( "org.restlet.http.headers" );

if( headerForm == null ){
    headerForm = new Form();
}

headerForm.add( "Content-Type", "application/vnd.google-earth.kml+xml" );

attributes.put( "org.restlet.http.headers", headerForm );

Reply via email to