classpath
[Top][All Lists]
Advanced

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

FYI: gnu.java.net.protocol.http.Connection


From: Guilhem Lavaux
Subject: FYI: gnu.java.net.protocol.http.Connection
Date: Sat, 27 Dec 2003 17:29:08 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007

Hi,

Here are two fixes concerning HTTP. Briefly:
* receiveReply() must also add the reponse to the header list (maybe some doc should be added about it) * getHeaderField() and getHeaderFieldKey() must check the state of the connection and
try to open it if it's closed.

Guilhem.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.1723
diff -u -r1.1723 ChangeLog
--- ChangeLog   27 Dec 2003 13:38:17 -0000      1.1723
+++ ChangeLog   27 Dec 2003 16:21:36 -0000
@@ -1,5 +1,12 @@
 2003-12-27  Guilhem Lavaux <address@hidden>
 
+       * gnu/java/net/protocol/http/Connection.java
+       (receiveReply): Add the null header containing the reply of the server.
+       (getHeaderField, getHeaderFieldKey): Check whether the connection has
+       already been established.
+
+2003-12-27  Guilhem Lavaux <address@hidden>
+
        * java/io/CharArrayReader.java (read): It should throw
        IndexOutOfBoundsException and not ArrayIndexOutOfBoundsException (see
        mauve).
Index: gnu/java/net/protocol/http/Connection.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/gnu/java/net/protocol/http/Connection.java,v
retrieving revision 1.7
diff -u -r1.7 Connection.java
--- gnu/java/net/protocol/http/Connection.java  27 Dec 2003 12:58:35 -0000      
1.7
+++ gnu/java/net/protocol/http/Connection.java  27 Dec 2003 16:21:36 -0000
@@ -255,6 +255,8 @@
         || (line.length() < (idx + 6)))
       throw new IOException ("Server reply was unparseable: " + saveline);
 
+    headers.addHeaderField (null, line);
+
     line = line.substring (idx + 1);
     String code = line.substring (0, 3);
     
@@ -420,6 +422,16 @@
    */
   public String getHeaderField(int n)
   {
+    if (!connected)
+      try
+       {
+         connect();
+       }
+      catch (IOException e)
+       {
+         return null;
+       }
+
     return headers.getHeaderFieldValueByIndex (n);
   }
 
@@ -434,6 +446,16 @@
    */
   public String getHeaderFieldKey(int n)
   {
+    if (!connected)
+      try
+       {
+         connect();
+       }
+      catch (IOException e)
+       {
+         return null;
+       }
+
     return headers.getHeaderFieldKeyByIndex (n);
   }
 }

reply via email to

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