Re: Redirection not working with nethttpd
Gerd Stolpmann <[email protected]> Tue, 11 Aug 2009 23:25:54 +0200
| Newsgroups | gmane.comp.lang.ocaml.lib.net.devel |
|---|---|
| Message-ID | <[email protected]> |
Am Dienstag, den 11.08.2009, 21:55 +0200 schrieb Paolo Donadeo: > > If the Location header starts with "/", Nethttpd tries to do an > > "internal" redirect--that is, to rewrite the request and process it > > directly, instead of returning a 302 response to the client. > > Ok, I see. And, as expected: > > > I think you can fix it by giving a full URL in the Location header in this code: > > this solves the problem. In any case, I remain dubious about the > nature of this behavior: bug or feature? :-) This is a feature :-) It exists for compatibility with CGI, where a redirect to a URL starting with / has always been taken as internal redirect by web servers. Also, if such a redirect was sent to the web browser, this would be a violation of the HTTP protocol (although many browsers seem to handle this case). > I think "internal redirection" is a good feature and I don't think > this is the way it is supposed to work. Well, you are using the interface that is compatible with CGI, so you get also certain CGI quirks. > > The exception you see is raised in nethttpd_reactor.ml, apparently > > because the response has already been partially written. Possibly if > > you really want an internal redirect you aren't supposed to commit the > > channel? > > If I don't commit the channel another exception is raised: > > [test server] [err] [127.0.0.1] [POST /post_url] Nethttpd: Missing > response, replying 'Server Error' > > I believe this is correct: this is exactly the same exception you get > when you forget to commit the channel. The server tries to process the > response and finds it empty, so the exception. > > As a quick fix I'll send the full redirection path back to the client, > but I still think i miss something. I have no full answer yet - I need to dig further into the problem. It could easily be that you discovered a bug. I'll try to check that soon. Gerd -- ------------------------------------------------------------ Gerd Stolpmann, Bad Nauheimer Str.3, 64289 Darmstadt,Germany [email protected] http://www.gerd-stolpmann.de Phone: +49-6151-153855 Fax: +49-6151-997714 ------------------------------------------------------------ ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july