[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit HttpUnitOptions.java,1.20,1.21 WebClient.
Brought to you by:
russgold
From: Russell G. <rus...@us...> - 2002-06-26 15:48:59
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit In directory usw-pr-cvs1:/tmp/cvs-serv17599/src/com/meterware/httpunit Modified Files: HttpUnitOptions.java WebClient.java Log Message: Support acceptCookies global option Index: HttpUnitOptions.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- HttpUnitOptions.java 17 Jun 2002 21:22:05 -0000 1.20 +++ HttpUnitOptions.java 26 Jun 2002 15:48:56 -0000 1.21 @@ -49,9 +49,25 @@ _contentType = DEFAULT_CONTENT_TYPE; _postIncludesCharset = false; _acceptGzip = true; + _acceptCookies = true; } + /** + * Returns true if HttpUnit is accepting and saving cookies. The default is to accept them. + */ + public static boolean isAcceptCookies() { + return _acceptCookies; + } + + + /** + * Specifies whether HttpUnit should accept and send cookies. + */ + public static void setAcceptCookies( boolean acceptCookies ) { + _acceptCookies = acceptCookies; + } + /** * Returns true if any WebClient created will accept GZIP encoding of responses. The default is to accept GZIP encoding. @@ -341,6 +357,8 @@ private static final String DEFAULT_CONTENT_TYPE = "text/plain"; private static boolean _acceptGzip = true; + + private static boolean _acceptCookies = true; private static boolean _parserWarningsEnabled; Index: WebClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebClient.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- WebClient.java 14 May 2002 19:31:04 -0000 1.23 +++ WebClient.java 26 Jun 2002 15:48:56 -0000 1.24 @@ -376,6 +376,8 @@ * Updates the cookies maintained in this client based on new cookies requested by the server. **/ private void updateCookies( WebResponse response ) { + if (!HttpUnitOptions.isAcceptCookies()) return; + String[] names = response.getNewCookieNames(); for (int i = 0; i < names.length; i++) { addCookie( names[i], response.getNewCookieValue( names[i] ) ); |