[Httpunit-commit] CVS: httpunit/src/com/meterware/httpunit HttpUnitOptions.java,1.9,1.10 PostMethodW
Brought to you by:
russgold
|
From: Russell G. <rus...@us...> - 2001-08-21 19:56:24
|
Update of /cvsroot/httpunit/httpunit/src/com/meterware/httpunit
In directory usw-pr-cvs1:/tmp/cvs-serv18783/src/com/meterware/httpunit
Modified Files:
HttpUnitOptions.java PostMethodWebRequest.java WebForm.java
Log Message:
Allow users to disable sending the charset with POST requests
Index: HttpUnitOptions.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/HttpUnitOptions.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- HttpUnitOptions.java 2001/08/08 19:18:12 1.9
+++ HttpUnitOptions.java 2001/08/21 19:56:22 1.10
@@ -44,6 +44,7 @@
_redirectDelay = 0;
_characterSet = DEFAULT_CHARACTER_SET;
_contentType = DEFAULT_CONTENT_TYPE;
+ _postIncludesCharset = true;
}
@@ -81,6 +82,26 @@
/**
+ * Determines whether a normal POST request will include the character set in the content-type header.
+ * The default is to include it; however, some older servlet engines (most notably Tomcat 3.1) get confused
+ * when they see it.
+ **/
+ public static void setPostIncludesCharset( boolean postIncludesCharset )
+ {
+ _postIncludesCharset = postIncludesCharset;
+ }
+
+
+ /**
+ * Returns true if POST requests should include the character set in the content-type header.
+ **/
+ public static boolean isPostIncludesCharset()
+ {
+ return _postIncludesCharset;
+ }
+
+
+ /**
* Sets the default content type for pages which do not specify one.
**/
public static void setDefaultContentType( String contentType ) {
@@ -257,6 +278,8 @@
private static boolean _matchesIgnoreCase = true;
private static boolean _autoRefresh;
+
+ private static boolean _postIncludesCharset = true;
private static int _redirectDelay;
Index: PostMethodWebRequest.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/PostMethodWebRequest.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- PostMethodWebRequest.java 2001/07/31 16:08:59 1.15
+++ PostMethodWebRequest.java 2001/08/21 19:56:22 1.16
@@ -168,7 +168,9 @@
* Returns the content type of this message body.
**/
String getContentType() {
- return "application/x-www-form-urlencoded; charset=" + getRequest().getCharacterSet();
+ return "application/x-www-form-urlencoded" +
+ (!HttpUnitOptions.isPostIncludesCharset() ? ""
+ : "; charset=" + getRequest().getCharacterSet());
}
Index: WebForm.java
===================================================================
RCS file: /cvsroot/httpunit/httpunit/src/com/meterware/httpunit/WebForm.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- WebForm.java 2001/08/06 20:19:41 1.25
+++ WebForm.java 2001/08/21 19:56:22 1.26
@@ -698,6 +698,12 @@
return getValue( optionNode.getFirstChild() );
}
}
+
+
+ private String getTextValue( Node optionNode ) {
+ NamedNodeMap nnm = optionNode.getAttributes();
+ return getValue( optionNode.getFirstChild() );
+ }
}
|