Hello,

I am using annotation in a wadlServerResource in this way:

public class TestAnnot extends WadlServerResource {
    @Override
    protected void doInit() {
        getMetadataService().clearExtensions();
        getMetadataService().addExtension("json", MediaType.APPLICATION_JSON);
        getMetadataService().addExtension("html", MediaType.TEXT_HTML);
    }

    @Get("html")
    public Representation representHtml() {
    ....
    }

    @Get("json")
    public Representation representJson() {
    ....
    }


}

Now when I execute the following commands :

1/curl -v -H 'Accept: text/html' http://localhost:8180/test
* About to connect() to localhost port 8180 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 8180 (#0)
> GET /test HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k 
> zlib/1.2.3.3 libidn/1.15
> Host: localhost:8180
> Accept: text/html
> 
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Wed, 28 Jul 2010 21:52:42 GMT
< Accept-Ranges: bytes
< Server: Restlet-Framework/2.0.0
< Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
< Content-Type: text/html; charset=UTF-8
< 

2/ curl -v -H 'Accept: application/json' http://localhost:8180/test
* About to connect() to localhost port 8180 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 8180 (#0)
> GET /search/terms/ext:xslt HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k 
> zlib/1.2.3.3 libidn/1.15
> Host: localhost:8180
> Accept: application/json
> 
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Wed, 28 Jul 2010 21:54:37 GMT
< Accept-Ranges: bytes
< Server: Restlet-Framework/2.0.0
< Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
< Content-Type: application/json; charset=UTF-8
<

3/ curl -v -H 'Accept: image/jpeg' http://localhost:8180/test
* About to connect() to localhost port 8180 (#0)
*   Trying ::1... connected
* Connected to localhost (::1) port 8180 (#0)
> GET /search/terms/ext:xslt HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k 
> zlib/1.2.3.3 libidn/1.15
> Host: localhost:8180
> Accept: image/jpeg
> 
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Date: Wed, 28 Jul 2010 21:56:11 GMT
< Accept-Ranges: bytes
< Server: Restlet-Framework/2.0.0
< Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
< Content-Type: application/json; charset=UTF-8
< 

The two first tests are corrects but I do not understand why I do not get a 
status 406 to show that the image/jpeg is not supported by the server. 

It there a way to check the mediaType asked by the client at the server side 
and to send a status 406 when the mediaType is not supported by the server ?

Thanks in advance,
J-Christophe

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

Reply via email to