I echo anonymonk’s request for clarification. Plack/PSGI is server side. It doesn’t, so far, make sense to answer your question with Plack code. Here is some more complete stuff for anyone to play with. I would suggest that the URI object’s methods are superior to URI::Split, so I include them after the split. One thing you might consider, and who knows, might be leading to your problem, the server doesn’t get the fragment (I mention it partly because it was an issue for me once and you present it in code dealing with server responses). Only the client knows about fragments; you can scan the YAML dump and see everything the server code gets.
# Server
plackup -MYAML -e 'sub { warn Dump(+shift), $/; [ 200, [], [ "OHAI" ]]
+ }'
HTTP::Server::PSGI: Accepting connections at http://0:5000/
# Client
use 5.16.2;
use strict;
use HTTP::Request;
use LWP::UserAgent;
use URI::Split "uri_split";
my $uri = 'http://user:pass@localhost:5000/some/path?o=hai#frag';
my $request = HTTP::Request->new( GET => $uri );
my $user_agent = LWP::UserAgent->new;
my $response = $user_agent->request($request);
if ( $response->is_success )
{
my $uri = $response->request->uri;
my ( $scheme, $auth, $path, $query, $frag ) = uri_split($uri);
say join " + ", $scheme, $auth, $path, $query, $frag;
for my $method (qw/ authority host port path fragment query /)
{
printf "%12s -> %s\n", $method, $uri->$method;
}
}