[Httpunit-develop] httunit session handling
Brought to you by:
russgold
|
From: Santosh G. <gdr...@gm...> - 2014-11-04 13:17:59
|
Hi...
I am using HttpClient to handle session.Here is my code to handle session
using httpclient. But httpclient won't handle ajax calls.I am planning to
move to httpunit to overcome my problem.Basically I have a referral URL(or
authentication server) from which I need to get cookies and session and
store it in client.And use this client across website to get logged user
information.
What is the appropriate solution for this using httpunit.
credentialsURL="https://www.,,,,.com./sapLogin.aspxHOOK_URL=
https://authentication.server.address
&username=<username>&password=<password>";
try{
HttpEntity entity=null;
HttpGet httpget=null;
HttpResponse response=null;
httpclient = new DefaultHttpClient();
httpget = new HttpGet(credentialsURL);
httpget.setHeader(HttpHeaders.USER_AGENT, "Mozilla/5.0 (Windows NT
6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.120
Safari/535.2");
response = httpclient.execute(httpget);
entity = response.getEntity();
if (entity != null) {
EntityUtils.consume(entity);
}
}
catch(Exception e){
}
return httpclient;
|