in reply to Replicating curl's authentication in Perl

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.