Got it....

It was variable interpolation for a username with an '@' in it.

use LWP::UserAgent; my $target = 'sharegeo'; # opendepot, jorum, sharegeo my ($host, $username, $password, $realm, $sword_url, $collection) = () +; for ($target) { /opendepot/ && do { $host = 'devel.edina.ac.uk:1201'; $collection = '/sword-app/deposit/archive'; $username = 'myUsername'; $password = 'myPassword'; $realm = 'SWORD'; last; }; /jorum/ && do { $host = 'dev1.jorum.ac.uk'; $collection = '/sword/deposit/123456789/15'; $username = 'me%40this.domain'; $password = 'myPassword'; $realm = 'SWORD'; last; }; /sharegeo/ && do { $host = 'devel.edina.ac.uk:9248'; $collection = '/sword/deposit/123456789/2'; $username = 'me%40that.domain'; $password = 'anotherPassword'; $realm = 'SWORD'; last; }; } # file to send via POST: my $filename = "Broker_test_package.zip"; # A DSpace/Mets zip file my $file = ""; open(FILE, "$filename" ) or die('cant open input file'); binmode FILE; while(<FILE>) { $file .= $_; } close FILE; my $ua = LWP::UserAgent->new(); my $req = HTTP::Request->new( POST => 'http://'.$username.":".$passwor +d."@".$host.$collection ); #my $length = do {use bytes; length $file}; # Tell SWORD to process the contents of the zip file as DSpaceMets $req->header( 'X-Packaging' => 'http://purl.org/net/sword-types/METSDS +paceSIP', 'X-No-Op' => 'false', 'X-Verbose' => 'true', 'Content-Disposition' => "filename=$filename" ); $req->content_type( 'application/zip' ); $req->content( $file ); #$req->content_length($length); # Et Zzzzooo! my $res = $ua->request($req); if ($res->is_success) { print $res->content; } else { print $res->status_line, "\n"; }
.... and that works for both a perl application (EPrints) and a java one (DSpace) Thanks to those who helped (on-line and off-line)


-- Ian Stuart
A man depriving some poor village, somewhere, of a first-class idiot.

In reply to *solved* Re: Replicating curl's authentication in Perl by kiz
in thread Replicating curl's authentication in Perl by kiz

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.