如何在HttpUnit中处理会话

时间:2014-11-04 13:27:01

标签: java ajax session-cookies http-unit

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;

我正在使用HttpClient来处理session.Here是我使用httpclient处理会话的代码。但是httpclient不会处理ajax调用。 我打算转到httpunit来克服我的问题。 基本上我有一个推荐URL(或身份验证服务器),我需要从中获取cookie和会话并将其存储在客户端。 并在整个网站上使用此客户端来获取记录的用户信息。 使用httpunit对此有什么合适的解决方案。 credentialsURL =“HTTPS://www.,,,,.com./sapLogin.aspx HOOK_URL = HTTPS:?//authentication.server.address&用户名=安培;密码= “;

0 个答案:

没有答案