W3C home > Mailing lists > Public > www-jigsaw@w3.org > September to October 1996

HTTP/0.9 PUT, patch

From: Anselm Baird_Smith <abaird@www43.inria.fr>
Date: Tue, 22 Oct 1996 10:33:17 +0200 (MET DST)
Message-Id: <199610220833.KAA26825@www43.inria.fr>
To: www-jigsaw@w3.org

The enclosed patch fixes two bugs:
a) HTTP/0.9 PUT should now work,
b) HTTP/1.1 "Connection: close" is now implemented properly.

This patch also fixes the problem with keepAlive set to false.

Anselm.
===================================================================
RCS file: /afs/w3.org/CVS-Repository/WWW/Jigsaw/src/classes/w3c/jigsaw/http/Request.java,v
retrieving revision 1.15
diff -u -r1.15 Request.java
--- Request.java	1996/09/13 19:54:48	1.15
+++ Request.java	1996/10/22 08:25:51
@@ -36,8 +36,10 @@
 	}
     }
 
-    protected Client     client = null ;
-    protected MimeParser parser = null;
+    protected Client      client  = null;
+    protected MimeParser  parser  = null;
+    protected InputStream in      = null;
+    protected boolean     keepcon = true;
     boolean is_proxy = false;
 
     /**
@@ -84,11 +86,11 @@
 
     public boolean canKeepConnection() {
 	// HTTP/0.9 doesn't know about keeping connections alive:
-	if (major < 1)
+	if (( ! keepcon) || (major < 1))
 	    return false;
-	if ( minor >= 1 )
+	if ( minor >= 1 ) 
 	    // HTTP/1.1 keeps connections alive by default
-	    return true;
+	    return hasConnection("close") ? false : true;
 	// For HTTP/1.0 check the [proxy] connection header:
 	if ( is_proxy )
 	    return hasProxyConnection("keep-alive");
@@ -219,23 +221,28 @@
     public InputStream getInputStream()
 	throws IOException
     {
+	if ( in != null )
+	    return in;
 	// Find out which method is used to the length:
 	int len = getContentLength();
 	if ( len >= 0 ) {
-	    return new ContentLengthInputStream(parser.getInputStream(), len);
-	}
-	// No content length, try out chunked encoding:
-	String te[] = getTransferEncoding() ;
-	if ( te != null ) {
-	    for (int i = 0 ; i < te.length ; i++) {
-		if (te[i].equals("chunked")) 
-		    return new ChunkedInputStream(parser.getInputStream());
+	    in = new ContentLengthInputStream(parser.getInputStream(), len);
+	} else {
+	    // No content length, try out chunked encoding:
+	    String te[] = getTransferEncoding() ;
+	    if ( te != null ) {
+		for (int i = 0 ; i < te.length ; i++) {
+		    if (te[i].equals("chunked")) 
+			in = new ChunkedInputStream(parser.getInputStream());
+		}
 	    }
 	}
 	// Everything has failed, we assume the connection will close:
-	// FIXME CLOSE THE CONNECTION !
-	//	return parser.getInputStream();
-	return null;
+	if ( in == null ) {
+	    keepcon = false;
+	    in      = parser.getInputStream();
+	}
+	return in;
     }
 
     /**
Received on Tuesday, 22 October 1996 04:33:21 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:25 GMT