This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new 56f32fb9e9 Refactor. Re-order. No functional change.
56f32fb9e9 is described below
commit 56f32fb9e91bcb3971c1116345c3fcac59e52fb0
Author: Mark Thomas <[email protected]>
AuthorDate: Mon Mar 6 19:45:51 2023 +0000
Refactor. Re-order. No functional change.
---
java/org/apache/coyote/ajp/AjpProcessor.java | 45 ++++++++++++++--------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java
b/java/org/apache/coyote/ajp/AjpProcessor.java
index e0ec70c0fe..534c74ec78 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -1045,11 +1045,6 @@ public class AjpProcessor extends AbstractProcessor {
response.setCommitted(true);
- tmpMB.recycle();
- responseMsgPos = -1;
- responseMessage.reset();
- responseMessage.appendByte(Constants.JK_AJP13_SEND_HEADERS);
-
// Responses with certain status codes and/or methods are not
permitted to include a response body.
int statusCode = response.getStatus();
if (statusCode < 200 || statusCode == 204 || statusCode == 205 ||
statusCode == 304 ||
@@ -1058,7 +1053,28 @@ public class AjpProcessor extends AbstractProcessor {
swallowResponse = true;
}
- // HTTP header contents
+ // Prepare special headers
+ MimeHeaders headers = response.getMimeHeaders();
+ String contentType = response.getContentType();
+ if (contentType != null) {
+ headers.setValue("Content-Type").setString(contentType);
+ }
+ String contentLanguage = response.getContentLanguage();
+ if (contentLanguage != null) {
+ headers.setValue("Content-Language").setString(contentLanguage);
+ }
+ long contentLength = response.getContentLengthLong();
+ if (contentLength >= 0) {
+ headers.setValue("Content-Length").setLong(contentLength);
+ }
+
+ // Write AJP message header
+ tmpMB.recycle();
+ responseMsgPos = -1;
+ responseMessage.reset();
+ responseMessage.appendByte(Constants.JK_AJP13_SEND_HEADERS);
+
+ // Write HTTP response line
responseMessage.appendInt(statusCode);
if (sendReasonPhrase) {
String message = null;
@@ -1082,22 +1098,7 @@ public class AjpProcessor extends AbstractProcessor {
}
responseMessage.appendBytes(tmpMB);
- // Special headers
- MimeHeaders headers = response.getMimeHeaders();
- String contentType = response.getContentType();
- if (contentType != null) {
- headers.setValue("Content-Type").setString(contentType);
- }
- String contentLanguage = response.getContentLanguage();
- if (contentLanguage != null) {
- headers.setValue("Content-Language").setString(contentLanguage);
- }
- long contentLength = response.getContentLengthLong();
- if (contentLength >= 0) {
- headers.setValue("Content-Length").setLong(contentLength);
- }
-
- // Other headers
+ // Write headers
int numHeaders = headers.size();
responseMessage.appendInt(numHeaders);
for (int i = 0; i < numHeaders; i++) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]