File apache-tomcat-add-reason-phrase.patch of Package apache-tomcat

diff -Naru apache-tomcat-9.0.65-src_orig/java/org/apache/coyote/http11/Http11OutputBuffer.java apache-tomcat-9.0.65-src/java/org/apache/coyote/http11/Http11OutputBuffer.java
--- apache-tomcat-9.0.65-src_orig/java/org/apache/coyote/http11/Http11OutputBuffer.java	2022-07-14 21:28:53.000000000 +0900
+++ apache-tomcat-9.0.65-src/java/org/apache/coyote/http11/Http11OutputBuffer.java	2025-05-15 15:54:03.466128710 +0900
@@ -352,9 +352,27 @@
 
         headerBuffer.put(Constants.SP);
 
-        // The reason phrase is optional but the space before it is not. Skip
-        // sending the reason phrase. Clients should ignore it (RFC 7230) and it
-        // just wastes bytes.
+        // add reason phrase; required for certain clients
+        switch (status) {
+            case 200:
+                write(ByteChunk.convertToBytes("OK"));
+                break;
+            case 304:
+                write(ByteChunk.convertToBytes("Not Modified"));
+                break;
+            case 401:
+                write(ByteChunk.convertToBytes("Unauthorized"));
+                break;
+            case 404:
+                write(ByteChunk.convertToBytes("Not Found"));
+                break;
+            case 501:
+                write(ByteChunk.convertToBytes("Not Implemented"));
+                break;
+            case 503:
+                write(ByteChunk.convertToBytes("Service Unavailable"));
+                break;
+        }
 
         headerBuffer.put(Constants.CR).put(Constants.LF);
     }
openSUSE Build Service is sponsored by