From eb15b339a3a688cbb3b9a0c99dc1f062a5c5276b Mon Sep 17 00:00:00 2001 From: Eric Roth Date: Tue, 15 Sep 2015 22:31:07 -0400 Subject: Remove PushBackInputStream. --- core/src/main/java/fi/iki/elonen/NanoHTTPD.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'core/src/main') diff --git a/core/src/main/java/fi/iki/elonen/NanoHTTPD.java b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java index da87bbb..4da8c58 100644 --- a/core/src/main/java/fi/iki/elonen/NanoHTTPD.java +++ b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java @@ -49,7 +49,7 @@ import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; -import java.io.PushbackInputStream; +import java.io.BufferedInputStream; import java.io.RandomAccessFile; import java.io.UnsupportedEncodingException; import java.net.InetAddress; @@ -485,7 +485,7 @@ public abstract class NanoHTTPD { private final OutputStream outputStream; - private final PushbackInputStream inputStream; + private final BufferedInputStream inputStream; private int splitbyte; @@ -509,13 +509,13 @@ public abstract class NanoHTTPD { public HTTPSession(TempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream) { this.tempFileManager = tempFileManager; - this.inputStream = new PushbackInputStream(inputStream, HTTPSession.BUFSIZE); + this.inputStream = new BufferedInputStream(inputStream, HTTPSession.BUFSIZE); this.outputStream = outputStream; } public HTTPSession(TempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream, InetAddress inetAddress) { this.tempFileManager = tempFileManager; - this.inputStream = new PushbackInputStream(inputStream, HTTPSession.BUFSIZE); + this.inputStream = new BufferedInputStream(inputStream, HTTPSession.BUFSIZE); this.outputStream = outputStream; this.remoteIp = inetAddress.isLoopbackAddress() || inetAddress.isAnyLocalAddress() ? "127.0.0.1" : inetAddress.getHostAddress().toString(); this.headers = new HashMap(); @@ -703,6 +703,7 @@ public abstract class NanoHTTPD { this.rlen = 0; int read = -1; + this.inputStream.mark(HTTPSession.BUFSIZE); try { read = this.inputStream.read(buf, 0, HTTPSession.BUFSIZE); } catch (Exception e) { @@ -726,7 +727,8 @@ public abstract class NanoHTTPD { } if (this.splitbyte < this.rlen) { - this.inputStream.unread(buf, this.splitbyte, this.rlen - this.splitbyte); + this.inputStream.reset(); + this.inputStream.skip(this.splitbyte); } this.parms = new HashMap(); -- cgit v1.2.3