diff options
author | Richard van Nieuwenhoven <richard.vannieuwenhoven@adesso.at> | 2015-09-25 06:24:52 +0200 |
---|---|---|
committer | Richard van Nieuwenhoven <richard.vannieuwenhoven@adesso.at> | 2015-09-25 06:24:52 +0200 |
commit | 1ad52158b1bcd50e7315c71c3dcc33faa8cb057e (patch) | |
tree | 29f8fd552cfdcfffdc3603708c0f59449461d523 | |
parent | ece85f5c231d97828d861610ffddb12e6da7f6c2 (diff) | |
parent | eb15b339a3a688cbb3b9a0c99dc1f062a5c5276b (diff) | |
download | nanohttpd-1ad52158b1bcd50e7315c71c3dcc33faa8cb057e.tar.gz |
Merge pull request #230 from ravenchild/bufferChanges
Remove PushBackInputStream for issue #228.
-rw-r--r-- | core/src/main/java/fi/iki/elonen/NanoHTTPD.java | 12 |
1 files changed, 7 insertions, 5 deletions
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<String, String>(); @@ -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<String, String>(); |