Re: httunit session handling

Wolfgang Fahl <[email protected]> Wed, 05 Nov 2014 09:09:19 +0100
Newsgroups gmane.comp.web.httpunit.devel
Organization BITPlan GmbH
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============1922183343188983494==
Content-Type: multipart/alternative;
	boundary="------------020203060905050005030304"

This is a multi-part message in MIME format.
--------------020203060905050005030304
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 8bit

Hi Santosh,

thank you for your question,

you might want to place your question at:
http://stackoverflow.com/questions/tagged/http-unit
so that other's can profit from the discussion. To get an answer for
your question you also might want to supply a stripped down example that
shows exactly what your problem is. The stripped down example should be
in a shape that other's can try out what  you are experiencing.

Please note that javascript support in http-unit is limited. Your
mileage regarding ajax calls might therefore vary.

Cheers


Wolfgang

Am 04.11.14 um 14:17 schrieb Santosh Gdr:
> 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;
>
>
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> Httpunit-develop mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/httpunit-develop

-- 

BITPlan - smart solutions
Wolfgang Fahl
Pater-Delp-Str. 1, D-47877 Willich Schiefbahn
Tel. +49 2154 811-480, Fax +49 2154 811-481
Web: http://www.bitplan.de
BITPlan GmbH, Willich - HRB 6820 Krefeld, Steuer-Nr.: 10258040548, Geschäftsführer: Wolfgang Fahl 


--------------020203060905050005030304
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Santosh,<br>
    <br>
    thank you for your question,<br>
    <br>
    you might want to place your question at:<br>
    <a class="moz-txt-link-freetext" href="http://stackoverflow.com/questions/tagged/http-unit">http://stackoverflow.com/questions/tagged/http-unit</a><br>
    so that other's can profit from the discussion. To get an answer for
    your question you also might want to supply a stripped down example
    that<br>
    shows exactly what your problem is. The stripped down example should
    be in a shape that other's can try out what  you are experiencing. <br>
    <br>
    Please note that javascript support in http-unit is limited. Your
    mileage regarding ajax calls might therefore vary.<br>
    <br>
    Cheers<br>
    <br>
    <br>
    Wolfgang<br>
    <br>
    <div class="moz-cite-prefix">Am 04.11.14 um 14:17 schrieb Santosh
      Gdr:<br>
    </div>
    <blockquote
cite="mid:CAP9o19hYmhHEZZZe2XNqXUT+o_qoGpgrkZZzi6FGTiR2Sq-vuQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi...
        <div><br>
        </div>
        <div>
          <div>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.</div>
          <div>What is the appropriate solution for this using httpunit.</div>
          <div>credentialsURL="<a moz-do-not-send="true"
              href="https://www">https://www</a>.,,,,.com./sapLogin.aspxHOOK_URL=<a
              moz-do-not-send="true"
              href="https://authentication.server.address">https://authentication.server.address</a>&amp;username=&lt;username&gt;&amp;password=&lt;password&gt;";</div>
        </div>
        <div><br>
        </div>
        <div>
          <div>try{</div>
          <div><span class="" style="white-space:pre"> </span>HttpEntity
            entity=null;</div>
          <div><span class="" style="white-space:pre"> </span>HttpGet
            httpget=null;</div>
          <div><span class="" style="white-space:pre"> </span>HttpResponse
             response=null;</div>
          <div><span class="" style="white-space:pre"> </span></div>
          <div><span class="" style="white-space:pre"> </span>httpclient
            = new DefaultHttpClient();</div>
          <div><span class="" style="white-space:pre"> </span></div>
          <div><span class="" style="white-space:pre"> </span>      
             httpget = new HttpGet(credentialsURL);</div>
          <div><span class="" style="white-space:pre"> </span>     </div>
          <div><span class="" style="white-space:pre"> </span>      
             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");</div>
          <div><span class="" style="white-space:pre"> </span>      
             response = httpclient.execute(httpget);</div>
          <div><span class="" style="white-space:pre"> </span>       </div>
          <div><span class="" style="white-space:pre"> </span>      
             entity = response.getEntity();</div>
          <div><span class="" style="white-space:pre"> </span>        </div>
          <div><span class="" style="white-space:pre"> </span>      
             if (entity != null) {</div>
          <div><span class="" style="white-space:pre"> </span>        <span
              class="" style="white-space:pre"> </span></div>
          <div><span class="" style="white-space:pre"> </span>        <span
              class="" style="white-space:pre"> </span>EntityUtils.consume(entity);</div>
          <div><span class="" style="white-space:pre"> </span>        }</div>
          <div><span class="" style="white-space:pre"> </span>}</div>
          <div><span class="" style="white-space:pre"> </span>catch(Exception
            e){</div>
          <div><span class="" style="white-space:pre"> </span></div>
          <div><span class="" style="white-space:pre"> </span>}</div>
          <div><span class="" style="white-space:pre"> </span>return
            httpclient;</div>
          <div><span class="" style="white-space:pre"> </span></div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">------------------------------------------------------------------------------
</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Httpunit-develop mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/httpunit-develop">https://lists.sourceforge.net/lists/listinfo/httpunit-develop</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 

BITPlan - smart solutions
Wolfgang Fahl
Pater-Delp-Str. 1, D-47877 Willich Schiefbahn
Tel. +49 2154 811-480, Fax +49 2154 811-481
Web: <a class="moz-txt-link-freetext" href="http://www.bitplan.de">http://www.bitplan.de</a>
BITPlan GmbH, Willich - HRB 6820 Krefeld, Steuer-Nr.: 10258040548, Geschäftsführer: Wolfgang Fahl </pre>
  </body>
</html>

--------------020203060905050005030304--


--===============1922183343188983494==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------

--===============1922183343188983494==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop

--===============1922183343188983494==--