Mark,

On 6/22/23 12:09, Mark Thomas wrote:
On 22/06/2023 17:08, ma...@apache.org wrote:
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
      new 00e7d79d3b Refactor SimpleHTTPClient to read body as-is rather than via readLine()
00e7d79d3b is described below

commit 00e7d79d3be7aedf195241a18ceca638cdb11692
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jun 22 17:08:02 2023 +0100

     Refactor SimpleHTTPClient to read body as-is rather than via readLine()
     Update impacted tests so they still pass

Tested on Linux and about to test on Windows to make sure that aren't any OS specific line ending issues.

I would have expected this patch to /fix/ any OS-specific line-ending issues rather than introducing any new ones.

+1 to not modifying the entity in any way. LGTM.


--- a/test/org/apache/catalina/startup/SimpleHttpClient.java
+++ b/test/org/apache/catalina/startup/SimpleHttpClient.java
@@ -150,6 +150,13 @@ public abstract class SimpleHttpClient {
         return responseLine;
     }

+    public int getStatusCode() {
+        if (responseLine.length() < 13) {
+            throw new IllegalStateException();
+        }
+        return Integer.parseInt(responseLine.substring(9, 12));
+    }
+

This seems fragile. I know the only major versions of HTTP so far have been 0.9, 1.0, 1.1, and 2(.0) which doesn't use text-based status-lines, but a spec-compliant parser would have to grab everything in between the first and second spaces on the line.

https://datatracker.ietf.org/doc/html/rfc2616#section-3.1

I'm perfectly happy to have you say "we'll fix it if it ever breaks" but I know sometimes you have to balance your desire to be spec-compliant with your desire to not have to do stupid things.

:)

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to