Getting HTTP Headers - Case sensitive?
If I need to get a Slug header, I can do: Form headers = getRequest().getAttributes().get(org.restlet.http.headers); String slug = headers.getValues(Slug); but is that Slug or slug or does it not matter? For a header, it should be case-insensitive. --Alex Milowski
RE: Getting HTTP Headers - Case sensitive?
Hi Alex, No problem, the getValues(String name) method is case insensitive. There is also getValues(String, String, boolean) method which lets you control the case sensitivity. Best regards, Jerome -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Alex Milowski Envoyé : mercredi 4 avril 2007 08:14 À : discuss@restlet.tigris.org Objet : Getting HTTP Headers - Case sensitive? If I need to get a Slug header, I can do: Form headers = getRequest().getAttributes().get(org.restlet.http.headers); String slug = headers.getValues(Slug); but is that Slug or slug or does it not matter? For a header, it should be case-insensitive. --Alex Milowski
Re: can't integrate restlet with tomcat
Hello Ai Li, I tried the war sample [1] available on the faq page [2] and it succeed with no error. It may come from your Tomcat configuration, did you try to launch a sample servlet with Tomcat? Please follow this link [3] and particularly this one [4]. Best regards, Thierry Boileau [1] http://restlet.tigris.org/source/browse/restlet/trunk/modules/org.restlet.example/src/org/restlet/example/dist/testServlet.war [2] http://www.restlet.org/documentation/1.0/faq#02 [3] http://tomcat.apache.org/faq/classnotfound.html [4] http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html I tried to run restlet inside tomcat (with 4.x, 5.x, or 6.x) but always got the following exception. I tried all the versions and the error is always the same. I followed the instruction from FAQ as how to config restlet inside tomcat. Any help is highly appreciated. ***error from tomcat*** HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: Error allocating a servlet instance org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process (Http11Protocol.java:634) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) java.lang.Thread.run(Thread.java:595) root cause java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet java.lang.ClassLoader.defineClass1(Native Method) java.lang.ClassLoader.defineClass(ClassLoader.java:620) java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) java.net.URLClassLoader.defineClass(URLClassLoader.java:260) java.net.URLClassLoader.access$100(URLClassLoader.java:56) java.net.URLClassLoader$1.run(URLClassLoader.java:195) java.security.AccessController.doPrivileged(Native Method) java.net.URLClassLoader.findClass(URLClassLoader.java:188) java.lang.ClassLoader.loadClass(ClassLoader.java:306) sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) java.lang.ClassLoader.loadClass(ClassLoader.java:251) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java: 1273) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java: 1204) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process( Http11Protocol.java:634) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) java.lang.Thread.run(Thread.java:595)
RE: Representation getText() encoding problem
Hi Ozgun, Excellent point. This is clearly a bug that we will fix by using an InputStreamReader instead of a raw InputStream. We will also add the character set of the parent representation as a parameter of this toString() method. Best regards, Jerome -Message d'origine- De : Atacan, Ozgun [mailto:[EMAIL PROTECTED] Envoyé : mercredi 4 avril 2007 11:01 À : discuss@restlet.tigris.org Objet : Representation getText() encoding problem Hi, i am using getText() method of my Representations to use their content directly as a String object. But i have problems with special characters encoding . Might there be a bug inside ByteUtils.toString(InputStream inputStream) method ? StringBuilder sb = new StringBuilder(); InputStream is = new BufferedInputStream(inputStream); int nextByte = is.read(); while (nextByte != -1) { sb.append((char) nextByte); nextByte = is.read(); } As far as I know some unicode character can be more than one byte (two or three). Can this char datatype casting be a possible bug? Kind Regards Özgün Atacan ** ** The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the addressee(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. The views expressed in this email are those of the individual and not necessarily those of Sony or Sony affiliated companies. Sony email is for business use only. This email and any response may be monitored by Sony to be in compliance with Sonys global policies and standards
HTTP Headers
Hi, I would like to set the following HTTP headers in the response: Cache-Control: no-cache Pragma: no-cache Expires: 0 I can't set this directly as Restlet prevents me from setting standard HTTP headers. I've read the FAQ and the documentation and I understand that instead of trying to set standard HTTP headers directly I should be using the API, which is fine. However, I can't seem to find any reference to the headers above apart from the constants in HttpConstants. What should I be doing? Many thanks in advance, Dig.
Re: Representation getText() encoding problem
Hello Özgün, your remark has been taken into account in the SVN repository. Thanks for this report. A new toString method allows to use a decoding character set. It means that when calling the getText method on a representation, the latter provides its own character set. If null, a default character set applies (see class InputStreamReader). Best regards, Thierry Boileau Hi Ozgun, Excellent point. This is clearly a bug that we will fix by using an InputStreamReader instead of a raw InputStream. We will also add the character set of the parent representation as a parameter of this toString() method. Best regards, Jerome -Message d'origine- De : Atacan, Ozgun [mailto:[EMAIL PROTECTED] Envoyé : mercredi 4 avril 2007 11:01 À : discuss@restlet.tigris.org Objet : Representation getText() encoding problem Hi, i am using getText() method of my Representations to use their content directly as a String object. But i have problems with special characters encoding . Might there be a bug inside ByteUtils.toString(InputStream inputStream) method ? StringBuilder sb = new StringBuilder(); InputStream is = new BufferedInputStream(inputStream); int nextByte = is.read(); while (nextByte != -1) { sb.append((char) nextByte); nextByte = is.read(); } As far as I know some unicode character can be more than one byte (two or three). Can this char datatype casting be a possible bug? Kind Regards Özgün Atacan ** ** The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the addressee(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. The views expressed in this email are those of the individual and not necessarily those of Sony or Sony affiliated companies. Sony email is for business use only. This email and any response may be monitored by Sony to be in compliance with Sony’s global policies and standards
setting Client timeout
Hi, Is there a way to set connection timeout or read timeout parameters to our Client ? As i investigated release notes set/get timeout methods removed from org.restlet.Client class since RC-4. I know we can set this attributes in com.noelious.restlet.ext.httpclient.HttpClientHelper but i can't set this helper to my Client or access this helper from Client since getHelper() method is private. I have already done a workaround by extending Client class and implementing my own but i wanted to be sure if we have another cleaner way to do this.. Kind Regards Özgün Atacan The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the addressee(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. The views expressed in this email are those of the individual and not necessarily those of Sony or Sony affiliated companies. Sony email is for business use only. This email and any response may be monitored by Sony to be in compliance with Sonys global policies and standards
Re: setting Client timeout
Hi, Actually there is a proper way to do what you want. The javadocs of the client helper extension [1] provides a list of properties that can be set following this way : client.getContext().getParameters().add(name, value); We agree to say that the information is not easy to find. We will find a way to fix that point in the Restlet documentation site. Best regards, Thierry Boileau [1] http://www.restlet.org/documentation/1.0/ext/com/noelios/restlet/ext/httpclient/HttpClientHelper.html Hi, Is there a way to set connection timeout or read timeout parameters to our Client ? As i investigated release notes set/get timeout methods removed from org.restlet.Client class since RC-4. I know we can set this attributes in com.noelious.restlet.ext.httpclient.HttpClientHelper but i can’t set this helper to my Client or access this helper from Client since getHelper() method is private. I have already done a workaround by extending Client class and implementing my own but i wanted to be sure if we have another cleaner way to do this.. Kind Regards Özgün Atacan The information contained in this message or any of its attachments may be confidential and is intended for the exclusive use of the addressee(s). Any disclosure, reproduction, distribution or other dissemination or use of this communication is strictly prohibited without the express permission of the sender. The views expressed in this email are those of the individual and not necessarily those of Sony or Sony affiliated companies. Sony email is for business use only. This email and any response may be monitored by Sony to be in compliance with Sony’s global policies and standards
NPE with a simple Directory example
Hey All, I'm trying simply to access some files in a directory and am getting a NPE in the ApplicationDispatcher.handle method. Here's my example: TestLauncher.java import org.restlet.Component ; import org.restlet.data.Protocol; public class TestLauncher { public static void main(String[] args) { try { Component component = new Component(); component.getServers ().add(Protocol.HTTP, 8181); component.getClients().add(Protocol.FILE); component.getDefaultHost().attach(, new TestApplication()); component.start(); } catch (Exception e) { e.printStackTrace(); } } } TestApplication.java import org.restlet.Application; import org.restlet.Directory ; import org.restlet.Restlet; import org.restlet.Router; public class TestApplication extends Application { @Override public Restlet createRoot() { Router rootRouter = new Router(); Directory imagesDirectory = new Directory(getContext(), file:///C:/images/); rootRouter.attach(/images/, imagesDirectory); return rootRouter; } } And this is the error I get on every request to http://localhost:8181/images/somefile.gif java.lang.NullPointerException at com.noelios.restlet.application.ApplicationDispatcher.handle( ApplicationDispatcher.java:81) at com.noelios.restlet.TemplateDispatcher.handle(TemplateDispatcher.java :89) at org.restlet.Uniform.handle (Uniform.java:97) at org.restlet.Uniform.get(Uniform.java:74) at com.noelios.restlet.local.DirectoryResource.init( DirectoryResource.java:142) at com.noelios.restlet.Engine.createDirectoryResource (Engine.java:253) at org.restlet.Directory.findTarget(Directory.java:145) at org.restlet.Finder.handle(Finder.java:268) at org.restlet.Filter.doHandle(Filter.java:105) at org.restlet.Filter.handle (Filter.java:134) at org.restlet.Router.handle(Router.java:441) at org.restlet.Filter.doHandle(Filter.java:105) at org.restlet.Filter.handle(Filter.java:134) at org.restlet.Filter.doHandle(Filter.java :105) at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:87) at org.restlet.Filter.handle(Filter.java:134) at org.restlet.Filter.doHandle(Filter.java:105) at org.restlet.Filter.handle (Filter.java:134) at com.noelios.restlet.application.ApplicationHelper.handle( ApplicationHelper.java:92) at org.restlet.Application.handle(Application.java:290) at org.restlet.Filter.doHandle(Filter.java :105) at org.restlet.Filter.handle(Filter.java:134) at org.restlet.Router.handle(Router.java:441) at org.restlet.Filter.doHandle(Filter.java:105) at org.restlet.Filter.handle(Filter.java:134) at org.restlet.Router.handle(Router.java:441) at org.restlet.Filter.doHandle(Filter.java:105) at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:87) at org.restlet.Filter.handle(Filter.java :134) at org.restlet.Filter.doHandle(Filter.java:105) at org.restlet.Filter.handle(Filter.java:134) at com.noelios.restlet.component.ComponentHelper.handle( ComponentHelper.java:115) at org.restlet.Component.handle (Component.java:228) at org.restlet.Server.handle(Server.java:266) at com.noelios.restlet.ServerHelper.handle(ServerHelper.java:99) at com.noelios.restlet.http.HttpServerHelper.handle( HttpServerHelper.java :94) at com.noelios.restlet.ext.jetty.JettyServerHelper$WrappedServer.handle( JettyServerHelper.java:232) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java :458) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete ( HttpConnection.java:776) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:500) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209) at org.mortbay.jetty.HttpConnection.handle( HttpConnection.java:358) at org.mortbay.io.nio.SelectChannelEndPoint.run( SelectChannelEndPoint.java:336) at org.mortbay.thread.BoundedThreadPool$PoolThread.run( BoundedThreadPool.java:442) I'm using Jetty and the latest code (downloaded yesterday) from http://www.restlet.org/downloads/1.0/current.zip Am I missing something here? Thanks, Jeff
Re: NPE with a simple Directory example
Hello Jeff, your application has been instantiated with its parent context, i.e the one of the component. You should proceed like this component.getDefaultHost().attach(, new TestApplication(component.getContext())); Best regards, Thierry Boileau Hey All, I'm trying simply to access some files in a directory and am getting a NPE in the ApplicationDispatcher.handle method. Here's my example: TestLauncher.java import org.restlet.Component ; import org.restlet.data.Protocol; public class TestLauncher { public static void main(String[] args) { try { Component component = new Component(); component.getServers ().add(Protocol.HTTP, 8181); component.getClients().add(Protocol.FILE); component.getDefaultHost().attach(, new TestApplication()); component.start(); } catch (Exception e) { e.printStackTrace(); } } } TestApplication.java import org.restlet.Application; import org.restlet.Directory ; import org.restlet.Restlet; import org.restlet.Router; public class TestApplication extends Application { @Override public Restlet createRoot() { Router rootRouter = new Router(); Directory imagesDirectory = new Directory(getContext(), file:///C:/images/); rootRouter.attach(/images/, imagesDirectory); return rootRouter; } } And this is the error I get on every request to http://localhost:8181/images/somefile.gif java.lang.NullPointerException at com.noelios.restlet.application.ApplicationDispatcher.handle(ApplicationDispatcher.java:81) at com.noelios.restlet.TemplateDispatcher.handle(TemplateDispatcher.java:89) at org.restlet.Uniform.handle (Uniform.java:97) at org.restlet.Uniform.get(Uniform.java:74) at com.noelios.restlet.local.DirectoryResource.init(DirectoryResource.java:142) at com.noelios.restlet.Engine.createDirectoryResource (Engine.java:253) at org.restlet.Directory.findTarget(Directory.java:145) at org.restlet.Finder.handle(Finder.java:268) at org.restlet.Filter.doHandle(Filter.java:105) at org.restlet.Filter.handle (Filter.java:134) at org.restlet.Router.handle(Router.java:441) at org.restlet.Filter.doHandle(Filter.java:105) at org.restlet.Filter.handle(Filter.java:134) at org.restlet.Filter.doHandle(Filter.java :105) at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:87) at org.restlet.Filter.handle(Filter.java:134) at org.restlet.Filter.doHandle(Filter.java:105) at org.restlet.Filter.handle (Filter.java:134) at com.noelios.restlet.application.ApplicationHelper.handle(ApplicationHelper.java:92) at org.restlet.Application.handle(Application.java:290) at org.restlet.Filter.doHandle(Filter.java :105) at org.restlet.Filter.handle(Filter.java:134) at org.restlet.Router.handle(Router.java:441) at org.restlet.Filter.doHandle(Filter.java:105) at org.restlet.Filter.handle(Filter.java:134) at org.restlet.Router.handle(Router.java:441) at org.restlet.Filter.doHandle(Filter.java:105) at com.noelios.restlet.StatusFilter.doHandle(StatusFilter.java:87) at org.restlet.Filter.handle(Filter.java :134) at org.restlet.Filter.doHandle(Filter.java:105) at org.restlet.Filter.handle(Filter.java:134) at com.noelios.restlet.component.ComponentHelper.handle(ComponentHelper.java:115) at org.restlet.Component.handle (Component.java:228) at org.restlet.Server.handle(Server.java:266) at com.noelios.restlet.ServerHelper.handle(ServerHelper.java:99) at com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java :94) at com.noelios.restlet.ext.jetty.JettyServerHelper$WrappedServer.handle(JettyServerHelper.java:232) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:458) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete (HttpConnection.java:776) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:500) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:209) at org.mortbay.jetty.HttpConnection.handle ( HttpConnection.java:358) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:336) at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442) I'm using Jetty and the latest code (downloaded yesterday) from http://www.restlet.org/downloads/1.0/current. zip http://www.restlet.org/downloads/1.0/current.zip Am I missing something here? Thanks, Jeff
RE: SSLSession parameters?
Toby, I've entered an RFE to cover this requirement: Improve SSL support http://restlet.tigris.org/issues/show_bug.cgi?id=281 This will not be added to version 1.0 which is too close to be released, more likely in version 1.1. So, just forget about it... for now :) Best regards, Jerome -Message d'origine- De : Toby Thain [mailto:[EMAIL PROTECTED] Envoyé : mercredi 4 avril 2007 14:23 À : discuss@restlet.tigris.org Objet : Re: SSLSession parameters? On 4-Apr-07, at 4:16 AM, Jerome Louvel wrote: Hi Toby, Do you want to get an instance of javax.net.ssl.SSLSession? This seems to contain quite useful info. But I also see that you can use getSessionContext() to gain access to other sessions... May this be a confidentiality issue? What are the SSL session properties that you are actually interested in? I'm only interested in the session in which a request arrived. I'd like to inspect client certificate (getPeerCertificates()). This is normally possible, e.g. Apache's mod_ssl provides these: http:// www.modssl.org/docs/2.8/ssl_reference.html#ToC25 I also wish to require client authentication (setNeedClientAuth() on the SSLSocket). --Toby Best regards, Jerome -Message d'origine- De : Toby Thain [mailto:[EMAIL PROTECTED] Envoyé : mardi 3 avril 2007 21:52 À : discuss@restlet.tigris.org Objet : SSLSession parameters? Hi, I'd like to access some of the SSL session parameters for an HTTPS protocol handler. My head is spinning from looking at the source code. Can somebody drop me a simple clue as to approach, or should I just forget about the idea? :-) TIA, --Toby
AWS authentication on Macs
From a previous discussion (link below), I note that com.noelios.restlet.util.SecurityUtils compensates for a JDK bug by setting content-type to application/x-www-form-urlencoded when the java version is less than 1.5.10. Unfortunately, the patch number does not apply to Apple's JVM. I'm running 1.5.07, and the compensation results in a bad authenticator. With the source from trunk, if I comment out that bit so it will always be when no content-type is sepcified, authentication works fine. Original discussion: http://article.gmane.org/gmane.comp.java.restlet/898 Java system properties: java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition java.runtime.version=1.5.0_07-164 java.specification.name=Java Platform API Specification java.specification.vendor=Sun Microsystems Inc. java.specification.version=1.5 java.vendor=Apple Computer, Inc. java.vendor.url=http://apple.com/ java.vendor.url.bug=http://developer.apple.com/java/ java.version=1.5.0_07 java.vm.info=mixed mode, sharing java.vm.name=Java HotSpot(TM) Client VM java.vm.specification.name=Java Virtual Machine Specification java.vm.specification.vendor=Sun Microsystems Inc. java.vm.specification.version=1.0 java.vm.vendor=Apple Computer, Inc. java.vm.version=1.5.0_07-87 os.arch=i386 os.name=Mac OS X os.version=10.4.9