@@ -117,6 +117,7 @@ public class QwpWebSocketSender implements Sender {
117117 private static final String WRITE_PATH = "/write/v4" ;
118118 private final AckFrameHandler ackHandler = new AckFrameHandler (this );
119119 private final WebSocketResponse ackResponse = new WebSocketResponse ();
120+ private final String authorizationHeader ;
120121 private final int autoFlushBytes ;
121122 private final long autoFlushIntervalNanos ;
122123 // Auto-flush configuration
@@ -174,8 +175,10 @@ private QwpWebSocketSender(
174175 int autoFlushRows ,
175176 int autoFlushBytes ,
176177 long autoFlushIntervalNanos ,
177- int inFlightWindowSize
178+ int inFlightWindowSize ,
179+ String authorizationHeader
178180 ) {
181+ this .authorizationHeader = authorizationHeader ;
179182 this .host = host ;
180183 this .port = port ;
181184 this .tlsEnabled = tlsEnabled ;
@@ -224,8 +227,9 @@ public static QwpWebSocketSender connect(String host, int port) {
224227 * @return connected sender
225228 */
226229 public static QwpWebSocketSender connect (String host , int port , boolean tlsEnabled ) {
227- return connect (host , port , tlsEnabled ,
228- DEFAULT_AUTO_FLUSH_ROWS , DEFAULT_AUTO_FLUSH_BYTES , DEFAULT_AUTO_FLUSH_INTERVAL_NANOS );
230+ return connect (
231+ host , port , tlsEnabled , DEFAULT_AUTO_FLUSH_ROWS , DEFAULT_AUTO_FLUSH_BYTES , DEFAULT_AUTO_FLUSH_INTERVAL_NANOS
232+ );
229233 }
230234
231235 /**
@@ -240,13 +244,30 @@ public static QwpWebSocketSender connect(String host, int port, boolean tlsEnabl
240244 * @param autoFlushIntervalNanos age before flush in nanos (0 = no limit)
241245 * @return connected sender
242246 */
243- public static QwpWebSocketSender connect (String host , int port , boolean tlsEnabled ,
244- int autoFlushRows , int autoFlushBytes ,
245- long autoFlushIntervalNanos ) {
247+ public static QwpWebSocketSender connect (
248+ String host ,
249+ int port ,
250+ boolean tlsEnabled ,
251+ int autoFlushRows ,
252+ int autoFlushBytes ,
253+ long autoFlushIntervalNanos
254+ ) {
255+ return connect (host , port , tlsEnabled , autoFlushRows , autoFlushBytes , autoFlushIntervalNanos , null );
256+ }
257+
258+ public static QwpWebSocketSender connect (
259+ String host ,
260+ int port ,
261+ boolean tlsEnabled ,
262+ int autoFlushRows ,
263+ int autoFlushBytes ,
264+ long autoFlushIntervalNanos ,
265+ String authorizationHeader
266+ ) {
246267 QwpWebSocketSender sender = new QwpWebSocketSender (
247- host , port , tlsEnabled , DEFAULT_BUFFER_SIZE ,
248- autoFlushRows , autoFlushBytes , autoFlushIntervalNanos ,
249- 1 // window=1 for sync behavior
268+ host , port , tlsEnabled , DEFAULT_BUFFER_SIZE , autoFlushRows , autoFlushBytes , autoFlushIntervalNanos ,
269+ 1 , // window=1 for sync behavior
270+ authorizationHeader
250271 );
251272 sender .ensureConnected ();
252273 return sender ;
@@ -263,11 +284,17 @@ public static QwpWebSocketSender connect(String host, int port, boolean tlsEnabl
263284 * @param autoFlushIntervalNanos age before flush in nanos (0 = no limit)
264285 * @return connected sender
265286 */
266- public static QwpWebSocketSender connectAsync (String host , int port , boolean tlsEnabled ,
267- int autoFlushRows , int autoFlushBytes ,
268- long autoFlushIntervalNanos ) {
269- return connectAsync (host , port , tlsEnabled , autoFlushRows , autoFlushBytes , autoFlushIntervalNanos ,
270- DEFAULT_IN_FLIGHT_WINDOW_SIZE );
287+ public static QwpWebSocketSender connectAsync (
288+ String host ,
289+ int port ,
290+ boolean tlsEnabled ,
291+ int autoFlushRows ,
292+ int autoFlushBytes ,
293+ long autoFlushIntervalNanos
294+ ) {
295+ return connectAsync (
296+ host , port , tlsEnabled , autoFlushRows , autoFlushBytes , autoFlushIntervalNanos , DEFAULT_IN_FLIGHT_WINDOW_SIZE
297+ );
271298 }
272299
273300 /**
@@ -290,11 +317,24 @@ public static QwpWebSocketSender connectAsync(
290317 int autoFlushBytes ,
291318 long autoFlushIntervalNanos ,
292319 int inFlightWindowSize
320+ ) {
321+ return connectAsync (
322+ host , port , tlsEnabled , autoFlushRows , autoFlushBytes , autoFlushIntervalNanos , inFlightWindowSize , null
323+ );
324+ }
325+
326+ public static QwpWebSocketSender connectAsync (
327+ String host ,
328+ int port ,
329+ boolean tlsEnabled ,
330+ int autoFlushRows ,
331+ int autoFlushBytes ,
332+ long autoFlushIntervalNanos ,
333+ int inFlightWindowSize ,
334+ String authorizationHeader
293335 ) {
294336 QwpWebSocketSender sender = new QwpWebSocketSender (
295- host , port , tlsEnabled , DEFAULT_BUFFER_SIZE ,
296- autoFlushRows , autoFlushBytes , autoFlushIntervalNanos ,
297- inFlightWindowSize
337+ host , port , tlsEnabled , DEFAULT_BUFFER_SIZE , autoFlushRows , autoFlushBytes , autoFlushIntervalNanos , inFlightWindowSize , authorizationHeader
298338 );
299339 sender .ensureConnected ();
300340 return sender ;
@@ -309,8 +349,9 @@ public static QwpWebSocketSender connectAsync(
309349 * @return connected sender
310350 */
311351 public static QwpWebSocketSender connectAsync (String host , int port , boolean tlsEnabled ) {
312- return connectAsync (host , port , tlsEnabled ,
313- DEFAULT_AUTO_FLUSH_ROWS , DEFAULT_AUTO_FLUSH_BYTES , DEFAULT_AUTO_FLUSH_INTERVAL_NANOS );
352+ return connectAsync (
353+ host , port , tlsEnabled , DEFAULT_AUTO_FLUSH_ROWS , DEFAULT_AUTO_FLUSH_BYTES , DEFAULT_AUTO_FLUSH_INTERVAL_NANOS
354+ );
314355 }
315356
316357 /**
@@ -326,9 +367,7 @@ public static QwpWebSocketSender connectAsync(String host, int port, boolean tls
326367 */
327368 public static QwpWebSocketSender createForTesting (String host , int port , int inFlightWindowSize ) {
328369 return new QwpWebSocketSender (
329- host , port , false , DEFAULT_BUFFER_SIZE ,
330- DEFAULT_AUTO_FLUSH_ROWS , DEFAULT_AUTO_FLUSH_BYTES , DEFAULT_AUTO_FLUSH_INTERVAL_NANOS ,
331- inFlightWindowSize
370+ host , port , false , DEFAULT_BUFFER_SIZE , DEFAULT_AUTO_FLUSH_ROWS , DEFAULT_AUTO_FLUSH_BYTES , DEFAULT_AUTO_FLUSH_INTERVAL_NANOS , inFlightWindowSize , null
332371 );
333372 // Note: does NOT call ensureConnected()
334373 }
@@ -345,13 +384,15 @@ public static QwpWebSocketSender createForTesting(String host, int port, int inF
345384 * @return unconnected sender
346385 */
347386 public static QwpWebSocketSender createForTesting (
348- String host , int port ,
349- int autoFlushRows , int autoFlushBytes , long autoFlushIntervalNanos ,
350- int inFlightWindowSize ) {
387+ String host ,
388+ int port ,
389+ int autoFlushRows ,
390+ int autoFlushBytes ,
391+ long autoFlushIntervalNanos ,
392+ int inFlightWindowSize
393+ ) {
351394 return new QwpWebSocketSender (
352- host , port , false , DEFAULT_BUFFER_SIZE ,
353- autoFlushRows , autoFlushBytes , autoFlushIntervalNanos ,
354- inFlightWindowSize
395+ host , port , false , DEFAULT_BUFFER_SIZE , autoFlushRows , autoFlushBytes , autoFlushIntervalNanos , inFlightWindowSize , null
355396 );
356397 // Note: does NOT call ensureConnected()
357398 }
@@ -1012,7 +1053,7 @@ private void ensureConnected() {
10121053 // Connect and upgrade to WebSocket
10131054 try {
10141055 client .connect (host , port );
1015- client .upgrade (WRITE_PATH );
1056+ client .upgrade (WRITE_PATH , authorizationHeader );
10161057 } catch (Exception e ) {
10171058 client .close ();
10181059 client = null ;
0 commit comments