q re LWP:UserAgent and basic_authorization

D

dan baker

I am attempting to POST from one script to another within the same
directory, which happens to be under .htaccess basic_auth . I am kinda
weak on understanding how UserAgent interacts with basic auth, but
have finally got something limping along if I happen to have the
clear-text password for the current user.

what I am wondering is if there is a way for me to set up the request
with whatever the current credentials are for the current user of the
first script? Since the scripts are in the same directory, the same
person should be able to run both scripts. I want to avoid having the
clear-text passwords on the server if I can avoid it.

This is the snippet in question in case there is an easier/better way
to do it...

$ua = LWP::UserAgent->new ;
$req = POST 'http://fullurl.com/...'.'UI_Home.pl',
[
HTML_StartNewOrderError => $HTML_ErrorMsg ,
PatientMRN => $PatientMRN
] ;
$req->authorization_basic( $RemoteUser , $UserPass ); # CLEAR TEXT
PASS

$res = $ua->request($req);
if ($res->is_success ){
print "Content-type: text/html \n\n" ;
print $res->content ;
} else {
print STDERR "\t UserAgent message: ".$res->message."\n";
&ExitToBrowser('fatal',"UserAgent failed \n");
}
exit;


thanks,
Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top