Hi sync,
an application has its own tunnelfilter ready to work. If you want to
use it, there is nothing to do at all.
Could you explain us what you want to do?
The behaviour of the Tunnel Service is specified in the Restlet API (see
[1]) and implemented in the reference implementation (the Noelios Rest
Engine, whose package are like "com.noelios.restlet") with the
TunnelFilter [2].
Let me precise the behaviour of the TunnelFilter. It allows to update
the request accordingly to some parameters (specified in the query or
the request body).
- in case of a POST request:
if the entity (the web form) contains a field whose name is
"method" and whose value is, fo example, "PUT", the request's method is
updated to "PUT". It allows to use other kind of request methods in web
forms.
- in case of a GET request:
if the query contains the following parameter names: "charset",
"encoding", "media", "language", their values replace the corresponding
"ACCEPT" headers.
Uo must be aware that the parameter value must be part of the
list of all known charsets, media types, etc, specified by the metadata
service [3].
This class defines a list of default known metadata, but you can
add new ones like this :
+ application.getMetadataService().addExtension("de", new
Language("de", "German language"));
+ application.getMetadataService().addExtension("xml", new
MediaType("application/xml", "xml files"));
+ application.getMetadataService().addExtension("windows-1252",
new CharacterSet("windows-1252", "Windows character set"));
+ application.getMetadataService().addExtension("rar", new
Encoding("rar", "rar compression algorithm"));
I hope this will help you.
Thierry Boileau
[1]
http://www.restlet.org/documentation/1.0/api/org/restlet/service/TunnelService.html
[2]
http://www.restlet.org/documentation/1.0/nre/com/noelios/restlet/application/TunnelFilter.html
[3]
http://www.restlet.org/documentation/1.0/api/org/restlet/service/MetadataService.html
Hi all,
I tried to use TunnelFilter, however it fails with the following response:
The server has not found anything matching the request URI</h3><p>You can get
technical details ...
This is how I initialized TunnelFilter within ServletContainer.
...
Application application = getApplication();
if ((component != null) && (application != null)) {
// First, let's locate the closest component
Server server = new Server(component.getContext(),
(List<Protocol>) null, request.getLocalAddr(), request
.getLocalPort(), component);
result = new HttpServerHelper(server);
// Attach the application
String uriPattern = request.getContextPath()
+ request.getServletPath();
application.setTunnelService(new TunnelService(true, true, true));
TunnelFilter tn = new TunnelFilter(application);
component.getDefaultHost().attach(uriPattern, tn);
...
i have a client which retrieves a resource via the URI
http://localhost:8080/myrest/info?media=xml which causes the above error
reponse. Even if the queryString is removed http://localhost:8080/myrest/info
it still throws the same error response.
I am sure i have set the Resource to be able to return in XML representation as
when I removed the TunnelFilter, everything works fine.
component.getDefaultHost().attach(uriPattern, application); //it works.
Did I use TunnelFilter wrongly? What's is the correct way of using it?
Thanks.