Hi Pantelis, A late reply, but this is definitely possible by subclassing the org.restlet.representation.OutputRepresentation and its write(OutputStream) method.
Note that this approach can be convenient, especially if you are familiar with the Servlet API, but that it is potentially less scalable as it necessarily blocks a writing thread. Best regards, Jerome Louvel -- Restlet ~ Founder and Technical Lead ~ http://www.restlet.org Noelios Technologies ~ http://www.noelios.com -----Message d'origine----- De : Sopasakis Pantelis [mailto:ch...@mail.ntua.gr] Envoyé : dimanche 27 décembre 2009 22:24 À : discuss@restlet.tigris.org Objet : Re: Redirection? First of all, thanks for the replies! I know how to do that using HTML, PHP, JSP, JS etc... My BIG question is... is there really some way to do that using just HTTP? Something like an OutputStream *directly* to the client! Is it possible to think of a response returned to a client as a message written in a file or displayed on the screen. For example... ResponseOutputStream out = new ResponseOutputStream(); out.write("message 1"); out.write("message 2"); out.flush(); out.close(); Ok, I haven't seen that anywhere before, but I was just wandering if it is possible.. Ben wrote something about keeping a socket open; how can I do that? Pantelis On Mon, 2009-12-28 at 14:34 -0500, Matt Kennedy wrote: > "RFC 2616 :-) http://www.ietf.org/rfc/rfc2616.txt (2626 is the Y2K > RFC)" > > > Woops. Hm, next time I should probably copy/paste the link instead of > fat-fingering the name huh? > > > Rob is right about everything else here too, I should have made it > more clear that the meta-refresh trick is hardly optimal as the > wikipedia entry nicely states. It sounded like the countdown part was > really important to you though, but the combination of a redirect > status code and the meta-refresh header may give you really > inconsistent results. Do you know if you have the luxury of your > client base only using a particular user agent? > > > If you decide the countdown is that important, you may have to forgo > HTTP correctness and leave the status at 200. Despite it's deprecated > status, the meta-refresh at this moment still works in all the > browsers I have experience with if it isn't also contending with a > refresh directive. You can definitely use it to get your delayed > "redirect" effect. > > > -Matt > > On Dec 28, 2009, at 2:18 PM, Rob Heittman wrote: > > > RFC 2616 :-) http://www.ietf.org/rfc/rfc2616.txt (2626 is the Y2K > > RFC) > > > > > > Sopasakis -- as HTTP itself doesn't have a means of specifying a > > delay before a redirect, you won't get consistent behavior across > > every HTTP compliant client or library. Most user-agents will act > > immediately on an HTTP redirect status code (3xx) and ignore the > > entity, but supplying an HTML entity with the meta refresh tag may > > have the desired effect for some user-agents. > > > > > > The usual convention is to enclose a short HTML entity with a 3xx > > redirect, something like this: > > > > > > <html><head><title>Moved</title></head><body> > > Please click this link if you are not automatically redirected to: > > <a href="${new-location}">${new-location}</a> > > <script>window.location.href="$[new-location}";</script> > > </body> > > > > > > You can doctor up some variants of this using the meta refresh or > > Javascript timeouts, but I suspect getting consistent behavior > > across basic HTTP clients like curl and regular browsers like > > Firefox will be a challenge, since you're operating at the HTML/JS > > level and not really the HTTP level. If you find a great solution, > > please post it back! > > > > > > - Rob > > > > On Mon, Dec 28, 2009 at 1:42 PM, Matt Kennedy <stinkym...@gmail.com> > > wrote: > > If you want this to be an official HTTP redirect, for > > example a 301, 302, 303, 307 status code, then you can set > > that status code in the response object and set the entity > > to be some html that will do your refresh to the new URL, > > plus the countdown. Be careful if you choose to go with 301 > > or 302 as the response code, read IETF RFC 2626 for details. > > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=24334 95 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2448275