REQUEST_URI will be in: Mojo support
I’ve got a comment about “What about Mojo?” on my yesterday’s blog post, and I answered Mojo is something different that implements everything from the ground up, but it was actually easy to write a Mojo adapter for PSGI by mimicking their CGI adapter. So here you go: Mojo::Server::PSGI.
mst looked at my blog post and FAQ and whined that being unable to distinguish /foo/bar from /foo%2fbar just breaks the whole Catalyst, which is actually true (and that’s why their CGI engine is broken). We talked about it for an hour and agreed to include REQUEST_URI, the undecoded raw URI (required) in the $env hash.
I understand that it’s kind of orthogonal and inconsistent to incldue REQUEST_URI rather than RAW_SCRIPT_NAME and RAW_PATH_INFO, but here’s why: some environments, like CGI adapters, can’t really tell RAW_* because they’re already decoded by servers. To (unreliably) get those values you should estimate and reconstruct from REQUEST_URI. That means if you have REQUEST_URI (the unparsed full URI including query strings if any) then you can programatically construct undecoded version of SCRIPT_NAME and PATH_INFO really easily. And REQUEST_URI is, even though it’s not speced in RFC 3875, set almost everywhere in CGI/FastCGI server implementations.
mst and I agreed that Catalyst and most frameworks that want full control over URI mapping would be fine with this REQUEST_URI addition. I updated the test case and included support for REQUEST_URI in all Plack servers, with the help of kazuho’s HTTP::Parser::XS update.
We’ll need to provide a nice wrapper methods on Plack::Request so the users can get the “base path” (the application base hosted path) and normalized URI etc. Currently you can get the raw URI (path + query) with $req->request_uri and normalized URI with $req->uri but to me they’re just confusing. I’ll redo and rename those methods to be more useful. Any suggestions on that would be welcome.
In #london.pm IRC channel last night I also got some chat with lathos (Simon Cozens) and konobi, where they ask me some interesting questions, especially since lathos is a happy user of HTTP::Engine and he wondered what are the actual benefits of switching from HTTP::Engine to PSGI/Plack stack.
Based on the chat with lathos, konobi and mst I updated the FAQ to include those questions and answers. This makes an awesome FAQ list. If you have more questions that are not answered, don’t hesitate to ask on comments or on IRC channel #http-engine on irc.perl.org.