# HG changeset patch # User Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com> # Date 1629195522 -7200 # Node ID eaad79c3235f81f256d8d0bb50657aebd641598c # Parent 95d1b0a38aede2391e71da9edecafa01074587d5 Make the fake prompts at block ends optional So we can turn them off during file uploads diff --git a/src/main/java/org/monetdb/mcl/net/MapiSocket.java b/src/main/java/org/monetdb/mcl/net/MapiSocket.java --- a/src/main/java/org/monetdb/mcl/net/MapiSocket.java +++ b/src/main/java/org/monetdb/mcl/net/MapiSocket.java @@ -90,7 +90,7 @@ public class MapiSocket { /* cannot (yet /** The TCP Socket timeout in milliseconds. Default is 0 meaning the timeout is disabled (i.e., timeout of infinity) */ private int soTimeout = 0; /** Stream from the Socket for reading */ - private InputStream fromMonet; + private BlockInputStream fromMonet; /** Stream from the Socket for writing */ private OutputStream toMonet; /** MCLReader on the InputStream */ @@ -720,6 +720,10 @@ public class MapiSocket { /* cannot (yet return handshakeOptions; } + public boolean setInsertFakeFlushes(boolean b) { + return fromMonet.setInsertFakeFlush(b); + } + /** * Inner class that is used to write data on a normal stream as a * blocked stream. A call to the flush() method will write a @@ -852,6 +856,7 @@ public class MapiSocket { /* cannot (yet private int readPos = 0; private int blockLen = 0; private final byte[] block = new byte[BLOCK + 3]; // \n.\n + private boolean insertFakeFlush = true; /** * Constructs this BlockInputStream, backed by the given @@ -864,6 +869,12 @@ public class MapiSocket { /* cannot (yet super(new BufferedInputStream(in)); } + public boolean setInsertFakeFlush(boolean doFake) { + boolean old = insertFakeFlush; + insertFakeFlush = doFake; + return old; + } + @Override public int available() { return blockLen - readPos; @@ -985,10 +996,12 @@ public class MapiSocket { /* cannot (yet block[blockLen++] = '\n'; } // insert 'fake' flush - for (byte b: LineType.PROMPT.bytes()) { - block[blockLen++] = b; + if (insertFakeFlush) { + for (byte b : LineType.PROMPT.bytes()) { + block[blockLen++] = b; + } + block[blockLen++] = '\n'; } - block[blockLen++] = '\n'; if (debug) log("RD ", "inserting prompt", true); }