classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Re: Patch: FYI: fix http Headers oddity


From: Bryce McKinlay
Subject: [cp-patches] Re: Patch: FYI: fix http Headers oddity
Date: Mon, 16 May 2005 18:17:20 -0400
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

Does anyone know why we use the custom "LineInputStream" class instead of, say, BufferedReader here? At one point BufferedReader.readLine() was buggy and could "read too much" and block before returning a line, but I believe we have fixed that. Code re-use would help to avoid bugs like this ;-)

Bryce


Tom Tromey wrote:

I'm checking this in on the trunk, the 4.0 branch, and Classpath.

This fixes a bug that occurs when an http server erroneously uses \n
as a line terminator rather than \r\n.  This lets us use a certain web
applet I ran across.

Tom

Index: ChangeLog
from  Tom Tromey  <address@hidden>
        * gnu/java/net/protocol/http/Headers.java (parse): Include final
        character of line.

Index: gnu/java/net/protocol/http/Headers.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/protocol/http/Headers.java,v
retrieving revision 1.2
diff -u -r1.2 Headers.java
--- gnu/java/net/protocol/http/Headers.java 18 Apr 2005 18:40:23 -0000 1.2
+++ gnu/java/net/protocol/http/Headers.java 16 May 2005 20:59:21 -0000
@@ -323,7 +323,10 @@
        if (c1 == ' ' || c1 == '\t')
          {
            // Continuation
-            value.append(line.substring(0, len - 1));
+           int last = len - 1;
+           if (line.charAt(last) != '\r')
+             ++last;
+            value.append(line.substring(0, last));
          }
        else
          {
@@ -340,7 +343,10 @@
                di++;
              }
            while (di < len && line.charAt(di) == ' ');
-            value.append(line.substring(di, len - 1));
+           int last = len - 1;
+           if (line.charAt(last) != '\r')
+             ++last;
+            value.append(line.substring(di, last));
          }
      }
  }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]