Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
1. Error on a first pass: "Can't call method "clone" on unblessed reference at /usr/share/perl5/HTTP/ line 32."

2. Shouldn't the %ENV variable names be mapped to the a-bit-different HTTP Header names?

3. And we are passing a hashref to the HTTP::Request constructor, but it expects an arrayref (solved via this node).

Changed code:
my %env_to_httpheader = ( 'HTTP_USER_AGENT' => 'User-Agent', 'HTTP_HOST' => 'Host', 'HTTP_TE' => 'Accept-Encoding', 'CONTENT_LENGTH' => 'Content-Length', # from here on blurry from memory: (and probably more to inclu +de as well..) 'CONTENT_ENCODING' => 'Content-Encoding', 'CONTENT_TYPE' => 'Content-Type', ); my $headers; foreach my $key (keys %env_to_httpheader) { if (exists $ENV{$key}) { # $headers->{ $env_to_httpheader{$key} } = $ENV{$key}; # "The optional $header argument should be a reference + to an HTTP::Headers object or a plain array reference of key/value p +airs." push(@{ $headers }, $env_to_httpheader{$key}); push(@{ $headers }, $ENV{$key}); } }

Result: After changing this, it works!

Any leftovers, hints, tweaks for this piece of code before I move it to production code? For example, a module for the ENV to HTTP Header translation, or similar improvements?

2c: A lengthy hack, isn't it? Just to get a HTTP::Response out of Once more, I dislike this

In reply to Re^4: Does CGI::Application expose a HTTP::Request object? by isync
in thread Does CGI::Application expose a HTTP::Request object? by isync

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (6)
    As of 2018-06-23 02:48 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (125 votes). Check out past polls.