This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/11.0.x by this push:
new 2f63ba186c Correctly record request start time
2f63ba186c is described below
commit 2f63ba186c40af06af9f7e176a9e686f40e070e5
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Sep 24 15:41:43 2024 +0100
Correctly record request start time
(System.nanoTime() can return negative values)
---
java/org/apache/coyote/http11/Http11InputBuffer.java | 5 ++---
java/org/apache/coyote/http2/Stream.java | 4 +---
webapps/docs/changelog.xml | 4 ++++
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/java/org/apache/coyote/http11/Http11InputBuffer.java
b/java/org/apache/coyote/http11/Http11InputBuffer.java
index 22232913ac..2e6d0e885a 100644
--- a/java/org/apache/coyote/http11/Http11InputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11InputBuffer.java
@@ -335,8 +335,6 @@ public class Http11InputBuffer implements InputBuffer,
ApplicationBufferHandler,
wrapper.setReadTimeout(keepAliveTimeout);
}
if (!fill(false)) {
- // A read is pending, so no longer in initial state
- parsingRequestLinePhase = 1;
return false;
}
// At least one byte of the request has been received.
@@ -358,7 +356,8 @@ public class Http11InputBuffer implements InputBuffer,
ApplicationBufferHandler,
}
// Set the start time once we start reading data (even if it is
// just skipping blank lines)
- if (request.getStartTimeNanos() < 0) {
+ if (parsingRequestLinePhase == 0) {
+ parsingRequestLinePhase = 1;
request.setStartTimeNanos(System.nanoTime());
}
chr = byteBuffer.get();
diff --git a/java/org/apache/coyote/http2/Stream.java
b/java/org/apache/coyote/http2/Stream.java
index a070909617..08b1fc8a02 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -157,9 +157,7 @@ class Stream extends AbstractNonZeroStream implements
HeaderEmitter {
this.coyoteResponse.setOutputBuffer(http2OutputBuffer);
this.coyoteRequest.setResponse(coyoteResponse);
this.coyoteRequest.protocol().setString("HTTP/2.0");
- if (this.coyoteRequest.getStartTimeNanos() < 0) {
- this.coyoteRequest.setStartTimeNanos(System.nanoTime());
- }
+ this.coyoteRequest.setStartTimeNanos(System.nanoTime());
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 246567ac36..8b50fceea2 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -153,6 +153,10 @@
input. Prior to this change, the output may have wrong by one second in
some cases. Pull request <pr>751</pr> provided by Chenjp. (markt)
</fix>
+ <fix>
+ Request start time may not have been accurately recorded for HTTP/1.1
+ requests preceded by a large number of blank lines. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]