You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mi...@apache.org on 2019/11/13 22:18:41 UTC
[tomcat] branch master updated: Properly calculate dynamic parts of
ErrorReportValve response for TestHttp2InitialConnection
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new df08451 Properly calculate dynamic parts of ErrorReportValve response for TestHttp2InitialConnection
df08451 is described below
commit df084515c34328f2186f5d43a993c798ff00b729
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Wed Nov 13 23:12:09 2019 +0100
Properly calculate dynamic parts of ErrorReportValve response for TestHttp2InitialConnection
---
.../coyote/http2/TestHttp2InitialConnection.java | 20 +++++++++++++++++---
webapps/docs/changelog.xml | 6 ++++++
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/test/org/apache/coyote/http2/TestHttp2InitialConnection.java b/test/org/apache/coyote/http2/TestHttp2InitialConnection.java
index a362a19..1a99c3a 100644
--- a/test/org/apache/coyote/http2/TestHttp2InitialConnection.java
+++ b/test/org/apache/coyote/http2/TestHttp2InitialConnection.java
@@ -115,7 +115,7 @@ public class TestHttp2InitialConnection extends Http2TestBase {
* This will vary depending on where the test is run due to:
* - The length of the version string that appears once in the error
* page
- * - The status header uses a UTF-8 EM dash. When running in an IDE
+ * - The status header uses a UTF-8 EN dash. When running in an IDE
* the UTF-8 properties files will be used directly rather than
* after native2ascii conversion.
*
@@ -124,10 +124,24 @@ public class TestHttp2InitialConnection extends Http2TestBase {
int serverInfoLength = ServerInfo.getServerInfo().getBytes().length;
StringManager sm = StringManager.getManager(
ErrorReportValve.class.getPackage().getName(), Locale.ENGLISH);
+ String reason = sm.getString("http." + testData.getExpectedStatus() + ".reason");
+ int descriptionLength = sm.getString("http." + testData.getExpectedStatus() + ".desc")
+ .getBytes(StandardCharsets.UTF_8).length;
int statusHeaderLength = sm
- .getString("errorReportValve.statusHeader", "", "")
+ .getString("errorReportValve.statusHeader",
+ String.valueOf(testData.getExpectedStatus()), reason)
+ .getBytes(StandardCharsets.UTF_8).length;
+ int typeLabelLength = sm.getString("errorReportValve.type")
+ .getBytes(StandardCharsets.UTF_8).length;
+ int statusReportLabelLength = sm.getString("errorReportValve.statusReport")
+ .getBytes(StandardCharsets.UTF_8).length;
+ int descriptionLabelLength = sm.getString("errorReportValve.description")
.getBytes(StandardCharsets.UTF_8).length;
- int len = 708 + serverInfoLength + statusHeaderLength * 2;
+ // 196 bytes is the static length of the pure HTML code from the ErrorReportValve
+ int len = 196 + org.apache.catalina.util.TomcatCSS.TOMCAT_CSS
+ .getBytes(StandardCharsets.UTF_8).length +
+ typeLabelLength + statusReportLabelLength + descriptionLabelLength +
+ descriptionLength + serverInfoLength + statusHeaderLength * 2;
String contentLength = String.valueOf(len);
return getResponseBodyFrameTrace(streamId,
testData.getExpectedStatus(), "text/html;charset=utf-8",
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 08598fc..bf9dacc 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -141,6 +141,12 @@
with <code>ping_mode="I"</code>, the <code>CPING</code>
message will not always be followed by the start of a request. (markt)
</fix>
+ <fix>
+ Properly calculate all dynamic parts of the ErrorReportValve response
+ on the fly in
+ <code>org.apache.coyote.http2.TestHttp2InitialConnection</code>.
+ (michaelo)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org