Re: set timeout

"Wolfgang Fahl" <[email protected]> Tue, 18 Aug 2009 19:23:48 +0200
Newsgroups gmane.comp.web.httpunit.devel
Organization BITPlan GmbH
Message-ID <[email protected]>
Dear Wilson,

your wrote:
> 
> Hi all,
> 
> i try to receive a website with different proxies.
> I'd like to set an timeout to sort out slow proxies.
> 
> I tried following code but no luck.
> 
> Any help on that?
> 
> public static String getUrl(String pUrl, ProxyUnit pUnit, int pTimeout)
>  {
>  String body = null;
> 
>  try
>  {
> WebConversation wc = new WebConversation();
> wc.setProxyServer(pUnit.getIp(), pUnit.getPort());
> 
> wc.set_connectTimeout(pTimeout);
> wc.set_readTimeout(pTimeout);
> 
> HttpUnitOptions.setScriptingEnabled(false);
> 
> WebRequest req = new GetMethodWebRequest(pUrl);
> WebResponse resp = wc.getResponse(req);
> 
> body = resp.getText();
>  }
>  catch (Exception ex)
>  {
> if (_logger.isDebugEnabled())
> {
> _logger.error(ex.getMessage());
> }
>  }
> 
>  return body;
>  }
You might want to create a JUnit test that describes 
what your expectation is. I assume you'll have to 
"inject" some kind of delay using the PseudoServer to 
get your point accross. 

Yours
  Wolfgang



BITPlan - smart solutions
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, VAT-ID: 10258040548, 
Geschäftsführer: Wolfgang Fahl

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july

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