Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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; } }

In reply to Re: Help with converting HTTP::Request to Plack::Request by Your Mother
in thread Help with converting HTTP::Request to Plack::Request by knox

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found