diff options
Diffstat (limited to 'libjava/classpath/gnu/java/net/protocol/http')
6 files changed, 32 insertions, 27 deletions
diff --git a/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java b/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java index 8abef71d521..8a30e51db57 100644 --- a/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java +++ b/libjava/classpath/gnu/java/net/protocol/http/ChunkedInputStream.java @@ -38,6 +38,8 @@ exception statement from your version. */ package gnu.java.net.protocol.http; +import gnu.java.lang.CPStringBuilder; + import java.io.IOException; import java.io.InputStream; import java.net.ProtocolException; @@ -113,7 +115,7 @@ public class ChunkedInputStream // Read chunk header int c, last = 0; boolean seenSemi = false; - StringBuilder buf = new StringBuilder(); + CPStringBuilder buf = new CPStringBuilder(); do { c = in.read(); diff --git a/libjava/classpath/gnu/java/net/protocol/http/Cookie.java b/libjava/classpath/gnu/java/net/protocol/http/Cookie.java index 0be7a097e5b..4482a121e59 100644 --- a/libjava/classpath/gnu/java/net/protocol/http/Cookie.java +++ b/libjava/classpath/gnu/java/net/protocol/http/Cookie.java @@ -38,6 +38,8 @@ exception statement from your version. */ package gnu.java.net.protocol.http; +import gnu.java.lang.CPStringBuilder; + import java.util.Date; /** @@ -139,7 +141,7 @@ public class Cookie public String toString(boolean showPath, boolean showDomain) { - StringBuilder buf = new StringBuilder(); + CPStringBuilder buf = new CPStringBuilder(); buf.append(name); buf.append('='); buf.append(value); diff --git a/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java b/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java index 9d19bfbdba4..44b1a608ac7 100644 --- a/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java +++ b/libjava/classpath/gnu/java/net/protocol/http/HTTPConnection.java @@ -39,6 +39,8 @@ exception statement from your version. */ package gnu.java.net.protocol.http; import gnu.classpath.SystemProperties; + +import gnu.java.lang.CPStringBuilder; import gnu.java.net.EmptyX509TrustManager; import java.io.BufferedInputStream; @@ -668,7 +670,7 @@ public class HTTPConnection Cookie[] cookies = cookieManager.getCookies(hostname, secure, path); if (cookies != null && cookies.length > 0) { - StringBuilder buf = new StringBuilder(); + CPStringBuilder buf = new CPStringBuilder(); buf.append("$Version=1"); for (int i = 0; i < cookies.length; i++) { @@ -827,7 +829,7 @@ public class HTTPConnection */ protected String getURI() { - StringBuilder buf = new StringBuilder(); + CPStringBuilder buf = new CPStringBuilder(); buf.append(secure ? "https://" : "http://"); buf.append(hostname); if (secure) diff --git a/libjava/classpath/gnu/java/net/protocol/http/Headers.java b/libjava/classpath/gnu/java/net/protocol/http/Headers.java index c8736bbac8f..690a0c65bd0 100644 --- a/libjava/classpath/gnu/java/net/protocol/http/Headers.java +++ b/libjava/classpath/gnu/java/net/protocol/http/Headers.java @@ -38,6 +38,8 @@ exception statement from your version. */ package gnu.java.net.protocol.http; +import gnu.java.lang.CPStringBuilder; + import gnu.java.net.LineInputStream; import java.io.IOException; @@ -280,7 +282,7 @@ class Headers implements Iterable<Headers.HeaderElement> (LineInputStream) in : new LineInputStream(in); String name = null; - StringBuilder value = new StringBuilder(); + CPStringBuilder value = new CPStringBuilder(); while (true) { String line = lin.readLine(); diff --git a/libjava/classpath/gnu/java/net/protocol/http/LimitedLengthInputStream.java b/libjava/classpath/gnu/java/net/protocol/http/LimitedLengthInputStream.java index 16cf56a2919..568f830fd47 100644 --- a/libjava/classpath/gnu/java/net/protocol/http/LimitedLengthInputStream.java +++ b/libjava/classpath/gnu/java/net/protocol/http/LimitedLengthInputStream.java @@ -1,5 +1,5 @@ /* LimitedLengthInputStream.java -- - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2008 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -57,20 +57,17 @@ class LimitedLengthInputStream private boolean eof; private InputStream in; private boolean doClose; - - + private void handleClose() throws IOException { eof = true; + if (doClose) - { - in.close(); - } + in.close(); else - { - connection.release(); - } + connection.release(); + in = null; connection = null; } @@ -85,7 +82,7 @@ class LimitedLengthInputStream * @param restrictLen if true the number of bytes that can be read * from this stream will be limited to maxLen, otherwise the number * of bytes is not restricted. - * + * * @param con the HTTPConnection associated with this stream * * @param doClose if true con will be closed when finished reading, @@ -98,7 +95,6 @@ class LimitedLengthInputStream HTTPConnection con, boolean doClose) throws IOException - { this.in = in; this.remainingLen = maxLen; @@ -122,7 +118,7 @@ class LimitedLengthInputStream return -1; // EOF int r; - + if (restrictLen) { r = in.read(); @@ -138,7 +134,7 @@ class LimitedLengthInputStream if (r == -1) handleClose(); } - + return r; } @@ -156,12 +152,12 @@ class LimitedLengthInputStream if (restrictLen && length > remainingLen) length = (int) remainingLen; - + int r = in.read(buffer, offset, length); - + if (-1 == r) handleClose(); - + if (restrictLen && r > 0) { remainingLen -= r; @@ -182,7 +178,7 @@ class LimitedLengthInputStream n = remainingLen; long r = in.skip(n); - + if (restrictLen) { remainingLen -= r; @@ -214,7 +210,7 @@ class LimitedLengthInputStream // it away. doClose = true; - + handleClose(); } } diff --git a/libjava/classpath/gnu/java/net/protocol/http/Request.java b/libjava/classpath/gnu/java/net/protocol/http/Request.java index 90e3b7a0d64..88e2fd077f2 100644 --- a/libjava/classpath/gnu/java/net/protocol/http/Request.java +++ b/libjava/classpath/gnu/java/net/protocol/http/Request.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.java.net.protocol.http; +import gnu.java.lang.CPStringBuilder; import gnu.java.net.LineInputStream; import gnu.java.util.Base64; @@ -628,7 +629,7 @@ public class Request { int len = text.length(); String key = null; - StringBuilder buf = new StringBuilder(); + CPStringBuilder buf = new CPStringBuilder(); Properties ret = new Properties(); boolean inQuote = false; for (int i = 0; i < len; i++) @@ -681,7 +682,7 @@ public class Request { int nc = connection.getNonceCount(nonce); String hex = Integer.toHexString(nc); - StringBuilder buf = new StringBuilder(); + CPStringBuilder buf = new CPStringBuilder(); for (int i = 8 - hex.length(); i > 0; i--) { buf.append('0'); @@ -752,7 +753,7 @@ public class Request int len = text.length(); String attr = null; - StringBuilder buf = new StringBuilder(); + CPStringBuilder buf = new CPStringBuilder(); boolean inQuote = false; for (int i = 0; i <= len; i++) { |