Commit 9e966176 authored by Dave Cridland's avatar Dave Cridland

Merge pull request #535 from cliffchung/master

Fix unicode read on input
parents 467a6b40 9ae64f50
...@@ -396,7 +396,7 @@ public class HttpBindServlet extends HttpServlet { ...@@ -396,7 +396,7 @@ public class HttpBindServlet extends HttpServlet {
class ReadListenerImpl implements ReadListener { class ReadListenerImpl implements ReadListener {
private final AsyncContext context; private final AsyncContext context;
private final StringBuilder buffer = new StringBuilder(512); private final ByteArrayOutputStream outStream = new ByteArrayOutputStream(1024);
private final String remoteAddress; private final String remoteAddress;
ReadListenerImpl(AsyncContext context) { ReadListenerImpl(AsyncContext context) {
...@@ -413,14 +413,14 @@ public class HttpBindServlet extends HttpServlet { ...@@ -413,14 +413,14 @@ public class HttpBindServlet extends HttpServlet {
byte b[] = new byte[1024]; byte b[] = new byte[1024];
int length; int length;
while (inputStream.isReady() && (length = inputStream.read(b)) != -1) { while (inputStream.isReady() && (length = inputStream.read(b)) != -1) {
buffer.append(new String(b, 0, length, StandardCharsets.UTF_8)); outStream.write(b, 0, length);
} }
} }
@Override @Override
public void onAllDataRead() throws IOException { public void onAllDataRead() throws IOException {
Log.trace("All data has been read from [" + remoteAddress + "]"); Log.trace("All data has been read from [" + remoteAddress + "]");
processContent(context, buffer.toString()); processContent(context, outStream.toString(StandardCharsets.UTF_8.name()));
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment