[Httpunit-commit] CVS: httpunit/src/com/meterware/servletunit RequestContext.java,1.4,1.5 ServletUni
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2004-10-27 00:57:44
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/servletunit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26105/src/com/meterware/servletunit Modified Files: RequestContext.java ServletUnitClient.java Log Message: bug #1051123 ServletUnit handling of parameter encoding was not cleaning up url-encodings Index: RequestContext.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/RequestContext.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- RequestContext.java 23 Jul 2004 01:31:04 -0000 1.4 +++ RequestContext.java 27 Oct 2004 00:57:33 -0000 1.5 @@ -45,7 +45,7 @@ RequestContext( URL url ) { _url = url; String file = _url.getFile(); - if (file.indexOf( '?' ) >= 0) loadParameters( file.substring( file.indexOf( '?' )+1 ), /* urlEncoded */ true ); + if (file.indexOf( '?' ) >= 0) loadParameters( file.substring( file.indexOf( '?' )+1 ) /* urlEncoded */ ); } @@ -99,7 +99,7 @@ * have_equals -> initial: record parameter with null value * have_value -> initial: record parameter with value **/ - void loadParameters( String queryString, boolean urlEncoded ) { + void loadParameters( String queryString ) { if (queryString.length() == 0) return; StringTokenizer st = new StringTokenizer( queryString, "&=", /* return tokens */ true ); int state = STATE_INITIAL; @@ -119,11 +119,11 @@ state = STATE_INITIAL; } } else if (state == STATE_INITIAL) { - name = (!urlEncoded) ? token : HttpUnitUtils.decode( token, getMessageEncoding() ); + name = HttpUnitUtils.decode( token, getMessageEncoding() ); value = ""; state = STATE_HAVE_NAME; } else { - value = (!urlEncoded) ? token : HttpUnitUtils.decode( token, getMessageEncoding() ); + value = HttpUnitUtils.decode( token, getMessageEncoding() ); state = STATE_HAVE_VALUE; } } @@ -152,7 +152,7 @@ private Hashtable getParameters() { if (_messageBody != null) { - loadParameters( getMessageBodyAsString(), /* urlEncoded */ false ); + loadParameters( getMessageBodyAsString() /* urlEncoded */ ); _messageBody = null; } if (_visibleParameters == null) { @@ -177,7 +177,7 @@ private String getMessageBodyAsString() { try { - return new String( _messageBody, getMessageEncoding() ); + return new String( _messageBody, "iso-8869-1" ); } catch (UnsupportedEncodingException e) { return ""; } Index: ServletUnitClient.java =================================================================== RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/servletunit/ServletUnitClient.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- ServletUnitClient.java 29 Sep 2004 17:15:26 -0000 1.15 +++ ServletUnitClient.java 27 Oct 2004 00:57:33 -0000 1.16 @@ -70,9 +70,15 @@ InvocationContext newInvocation( WebRequest request, FrameSelector frame ) throws IOException, MalformedURLException { + ByteArrayOutputStream baos = getMessageBody( request ); + return _invocationContextFactory.newInvocation( this, frame, request, getHeaderFields( request.getURL() ), baos.toByteArray() ); + } + + + ByteArrayOutputStream getMessageBody( WebRequest request ) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); writeMessageBody( request, baos ); - return _invocationContextFactory.newInvocation( this, frame, request, getHeaderFields( request.getURL() ), baos.toByteArray() ); + return baos; } |