src/share/classes/sun/rmi/transport/proxy/HttpInputStream.java

Print this page




  53             in.mark(0); // prevent resetting back to old marks
  54 
  55         // pull out header, looking for content length
  56 
  57         DataInputStream dis = new DataInputStream(in);
  58         String key = "Content-length:".toLowerCase();
  59         boolean contentLengthFound = false;
  60         String line;
  61         do {
  62             line = dis.readLine();
  63 
  64             if (RMIMasterSocketFactory.proxyLog.isLoggable(Log.VERBOSE)) {
  65                 RMIMasterSocketFactory.proxyLog.log(Log.VERBOSE,
  66                     "received header line: \"" + line + "\"");
  67             }
  68 
  69             if (line == null)
  70                 throw new EOFException();
  71 
  72             if (line.toLowerCase().startsWith(key)) {
  73                 if (contentLengthFound)
  74                     ; // what would we want to do in this case??
  75                 bytesLeft =
  76                     Integer.parseInt(line.substring(key.length()).trim());
  77                 contentLengthFound = true;
  78             }
  79 
  80             // The idea here is to go past the first blank line.
  81             // Some DataInputStream.readLine() documentation specifies that
  82             // it does include the line-terminating character(s) in the
  83             // returned string, but it actually doesn't, so we'll cover
  84             // all cases here...
  85         } while ((line.length() != 0) &&
  86                  (line.charAt(0) != '\r') && (line.charAt(0) != '\n'));
  87 
  88         if (!contentLengthFound || bytesLeft < 0) {
  89             // This really shouldn't happen, but if it does, shoud we fail??
  90             // For now, just give up and let a whole lot of bytes through...
  91             bytesLeft = Integer.MAX_VALUE;
  92         }
  93         bytesLeftAtMark = bytesLeft;
  94 




  53             in.mark(0); // prevent resetting back to old marks
  54 
  55         // pull out header, looking for content length
  56 
  57         DataInputStream dis = new DataInputStream(in);
  58         String key = "Content-length:".toLowerCase();
  59         boolean contentLengthFound = false;
  60         String line;
  61         do {
  62             line = dis.readLine();
  63 
  64             if (RMIMasterSocketFactory.proxyLog.isLoggable(Log.VERBOSE)) {
  65                 RMIMasterSocketFactory.proxyLog.log(Log.VERBOSE,
  66                     "received header line: \"" + line + "\"");
  67             }
  68 
  69             if (line == null)
  70                 throw new EOFException();
  71 
  72             if (line.toLowerCase().startsWith(key)) {
  73                 // if contentLengthFound is true
  74                 // we should probably do something here
  75                 bytesLeft =
  76                     Integer.parseInt(line.substring(key.length()).trim());
  77                 contentLengthFound = true;
  78             }
  79 
  80             // The idea here is to go past the first blank line.
  81             // Some DataInputStream.readLine() documentation specifies that
  82             // it does include the line-terminating character(s) in the
  83             // returned string, but it actually doesn't, so we'll cover
  84             // all cases here...
  85         } while ((line.length() != 0) &&
  86                  (line.charAt(0) != '\r') && (line.charAt(0) != '\n'));
  87 
  88         if (!contentLengthFound || bytesLeft < 0) {
  89             // This really shouldn't happen, but if it does, shoud we fail??
  90             // For now, just give up and let a whole lot of bytes through...
  91             bytesLeft = Integer.MAX_VALUE;
  92         }
  93         bytesLeftAtMark = bytesLeft;
  94