O/H Sudarshan Soma έγραψε:
Hi All,
I have a requirement to test webserver using perl scripts. The
webserver creates a sessionId after successfull authentication. Hence
for futher requests to the webserver, i need to send the sessionId
which is set in the browser/client . Can anyone please let me know how
can i do this.

Myperl script is something like this:

$requestString = "http://x.y.x.w";
$request = HTTP::Request->new(GET => $requestString);
$request->authorization_basic($userid, $passwd);
$request->push_header(Cookie => "SESSIONID=?????; path=/;"); ------>
capture session id from browser
rather:
---8<---
use HTTP::Cookies;
use HTTP::Request::Common;
use LWP::UserAgent;

$ua = LWP::UserAgent->new;
$requestString = "http://x.y.x.w";;
$ua->cookie_jar(HTTP::Cookies->new);
$result = $ua->request(HTTP::Request::Common::GET $requestString));
$ua->cookie_jar->extract_cookies($res);
#session id is now in the cookie jar. ``perldoc HTTP::Cookies''
#to read it
$anotherURI = "http://x.y.x.w/whatever";;
$requestObject = HTTP::Request::Common::GET $anotherURI;
#automatically add the cookies (including the session-id) to this request..
$ua->cookie_jar->add_cookie_header($requestObject);
$result = $ua->request($requestObject);

---8<---



Best Regards,
Pavan

---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscr...@perl.apache.org
For additional commands, e-mail: asp-h...@perl.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscr...@perl.apache.org
For additional commands, e-mail: asp-h...@perl.apache.org

Reply via email to