Author: bmaxwell
Date: 2012-02-23 18:38:51 -0500 (Thu, 23 Feb 2012)
New Revision: 1980
Modified:
branches/JBOSSWEB_2_0_0_GA_CP16_BZ794470/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java
branches/JBOSSWEB_2_0_0_GA_CP16_BZ794470/src/share/classes/org/apache/catalina/authenticator/SavedRequest.java
Log:
[BZ794470] fix POST content type incorrect for multipart forms after login
Modified:
branches/JBOSSWEB_2_0_0_GA_CP16_BZ794470/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java
===================================================================
---
branches/JBOSSWEB_2_0_0_GA_CP16_BZ794470/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java 2012-02-23
23:14:57 UTC (rev 1979)
+++
branches/JBOSSWEB_2_0_0_GA_CP16_BZ794470/src/share/classes/org/apache/catalina/authenticator/FormAuthenticator.java 2012-02-23
23:38:51 UTC (rev 1980)
@@ -436,7 +436,13 @@
// Set content type
MessageBytes contentType = MessageBytes.newInstance();
- contentType.setString("application/x-www-form-urlencoded");
+
+ //If no content type specified, use default for POST
+ String savedContentType = saved.getContentType();
+ if (savedContentType == null)
+ savedContentType = "application/x-www-form-urlencoded";
+
+ contentType.setString(savedContentType);
request.getCoyoteRequest().setContentType(contentType);
}
}
@@ -496,6 +502,10 @@
body.append(buffer, 0, bytesRead);
}
saved.setBody(body);
+
+ //Save content type, cannot assume application/x-www-form-urlencoded
+ //since it could be a multi-part form
+ saved.setContentType(request.getContentType());
}
saved.setMethod(request.getMethod());
Modified:
branches/JBOSSWEB_2_0_0_GA_CP16_BZ794470/src/share/classes/org/apache/catalina/authenticator/SavedRequest.java
===================================================================
---
branches/JBOSSWEB_2_0_0_GA_CP16_BZ794470/src/share/classes/org/apache/catalina/authenticator/SavedRequest.java 2012-02-23
23:14:57 UTC (rev 1979)
+++
branches/JBOSSWEB_2_0_0_GA_CP16_BZ794470/src/share/classes/org/apache/catalina/authenticator/SavedRequest.java 2012-02-23
23:38:51 UTC (rev 1980)
@@ -178,4 +178,17 @@
public void setBody(ByteChunk body) {
this.body = body;
}
+
+ /**
+ * The content type of the request, used if this is a POST.
+ */
+ private String contentType = null;
+
+ public String getContentType() {
+ return (this.contentType);
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
}
Show replies by date