[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit WebResponse.java,1.29,1.30
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2001-03-23 19:13:31
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv24514/src/com/meterware/httpunit
Modified Files:
WebResponse.java
Log Message:
Added improved cookie handling
Index: WebResponse.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebResponse.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- WebResponse.java 2001/01/02 15:20:29 1.29
+++ WebResponse.java 2001/03/23 19:13:27 1.30
@@ -367,14 +367,26 @@
}
+
private void recognizeOneCookie( String cookieSpec ) {
- StringTokenizer st = new StringTokenizer( cookieSpec, "=;" );
- String name = st.nextToken().trim();
- if (st.hasMoreTokens()) {
- String value = st.nextToken().trim();
- _newCookies.put( name, value );
- }
+ StringTokenizer st = new StringTokenizer( cookieSpec, ";" );
+ String token = st.nextToken().trim();
+ int i = token.indexOf("=");
+ if (i > -1) {
+ String name = token.substring(0, i).trim();
+ String value = stripQuote( token.substring( i+1, token.length() ).trim() );
+ _newCookies.put( name, value );
+ }
}
+
+
+ private String stripQuote( String value ) {
+ if (((value.startsWith("\"")) && (value.endsWith("\""))) ||
+ ((value.startsWith("'") && (value.endsWith("'"))))) {
+ return value.substring(1,value.length()-1);
+ }
+ return value;
+ }
private void readContentTypeHeader() {
|