You are right, I was staring at the undefined $ua (just a typo) and not seeing it, thank you.
Still, this doesn't seem to work in my test setup, i.e. apache as proxy in front of puppet. I get a "..timeout specified has expired: proxy: prefetch request body failed to 127.0.0.1:18140" in apache's log.
GETs do work, just PUTs fail. Config is
Listen 8140 <Proxy balancer://puppetmaster> BalancerMember http://127.0.0.1:18140 BalancerMember http://127.0.0.1:18141 </Proxy> <VirtualHost *:8140> SSLEngine On SSLCipherSuite SSLv2:-LOW:-EXPORT:RC4+RSA SSLCertificateFile /var/lib/puppet/ssl/certs/server.pem SSLCertificateKeyFile /var/lib/puppet/ssl/private_keys/server. +pem SSLCertificateChainFile /var/lib/puppet/ssl/ca/ca_crt.pem SSLCACertificateFile /var/lib/puppet/ssl/ca/ca_crt.pem SSLCARevocationFile /var/lib/puppet/ssl/ca/ca_crl.pem SSLVerifyClient require SSLVerifyDepth 1 SSLOptions +StdEnvVars RequestHeader set X-Client-DN %{SSL_CLIENT_S_DN}e RequestHeader set X-Client-Verify %{SSL_CLIENT_VERIFY}e <Location /> SetHandler balancer-manager Order allow,deny Allow from all </Location> ProxyPass / balancer://puppetmaster/ ProxyPassReverse / balancer://puppetmaster/ ProxyPreserveHost On ErrorLog /mirror/log/balancer_error_log CustomLog /mirror/log/balancer_access_log "%h %l %u %t \"%r\" +%>s %b \"%{SSL_CLIENT_S_DN}x\" \"%{User-Agent}i\"" </VirtualHost>
and the perl code is
{ open my $up, "<", "$_[0]" or die "Something went wrong: ".$!; binm +ode $up; my $ck = Digest::MD5->new; $ck->addfile($up); close $up; my $req = HTTP::Request::StreamingUpload->new( PUT => "https:// ".$server."/file_bucket_file/md5/".$ck->hexdigest, path => $_[0], headers => HTTP::Headers->new( 'Content-Type' => 'application/binary', 'Content-Length' => -s $_[0], 'Accept' => 's', ), ); my $res = $ua->request($req); die "Something went wrong: ".$res->status_line unless $res->is_suc +cess; return $res->content; }
SSL handshake does work, but the puppet process doesn't seem to receive any data (I'm tailing its debug log). Not sure if I am doing something wrong, or it is a problem in mod_proxy..

In reply to Re^4: Upload file to REST service by rgcosma
in thread Upload file to REST service by rgcosma

Title:
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, details, 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, summary, 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.