changeset 501:eaad79c3235f onclient

Make the fake prompts at block ends optional So we can turn them off during file uploads
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Tue, 17 Aug 2021 12:18:42 +0200 (2021-08-17)
parents 95d1b0a38aed
children 83354bd21320
files src/main/java/org/monetdb/mcl/net/MapiSocket.java
diffstat 1 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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);
 			}