changeset 5581:49a37df9e80f

8001242: Improve RMI HTTP conformance Reviewed-by: ahgross, mchung, smarks
author dmocek
date Mon, 19 Nov 2012 15:32:59 -0800
parents 2281f5670cc5
children 6f9dde55bd49
files src/share/classes/sun/rmi/transport/proxy/CGIHandler.java src/share/classes/sun/rmi/transport/proxy/HttpInputStream.java
diffstat 2 files changed, 17 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java	Mon Nov 19 13:52:08 2012 -0800
+++ b/src/share/classes/sun/rmi/transport/proxy/CGIHandler.java	Mon Nov 19 15:32:59 2012 -0800
@@ -285,11 +285,14 @@
                     "unexpected EOF reading server response");
 
             if (line.toLowerCase().startsWith(key)) {
-                if (contentLengthFound)
-                    ; // what would we want to do in this case??
-                responseContentLength =
-                    Integer.parseInt(line.substring(key.length()).trim());
-                contentLengthFound = true;
+                if (contentLengthFound) {
+                    throw new CGIServerException(
+                            "Multiple Content-length entries found.");
+                } else {
+                    responseContentLength =
+                        Integer.parseInt(line.substring(key.length()).trim());
+                    contentLengthFound = true;
+                }
             }
         } while ((line.length() != 0) &&
                  (line.charAt(0) != '\r') && (line.charAt(0) != '\n'));
--- a/src/share/classes/sun/rmi/transport/proxy/HttpInputStream.java	Mon Nov 19 13:52:08 2012 -0800
+++ b/src/share/classes/sun/rmi/transport/proxy/HttpInputStream.java	Mon Nov 19 15:32:59 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,11 +70,14 @@
                 throw new EOFException();
 
             if (line.toLowerCase().startsWith(key)) {
-                if (contentLengthFound)
-                    ; // what would we want to do in this case??
-                bytesLeft =
-                    Integer.parseInt(line.substring(key.length()).trim());
-                contentLengthFound = true;
+                if (contentLengthFound) {
+                    throw new IOException(
+                            "Multiple Content-length entries found.");
+                } else {
+                    bytesLeft =
+                        Integer.parseInt(line.substring(key.length()).trim());
+                    contentLengthFound = true;
+                }
             }
 
             // The idea here is to go past the first blank line.