Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/mcl/net/MapiSocket.java @ 422:8368cbc670bf
Send reply size and time zone during initial handshake
author | Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com> |
---|---|
date | Tue, 02 Feb 2021 13:50:13 +0100 (2021-02-02) |
parents | bf9f6b6ecf40 |
children | 788984342ae3 |
comparison
equal
deleted
inserted
replaced
421:163b784aa93b | 422:8368cbc670bf |
---|---|
120 public final static int BLOCK = 8 * 1024 - 2; | 120 public final static int BLOCK = 8 * 1024 - 2; |
121 | 121 |
122 /** A short in two bytes for holding the block size in bytes */ | 122 /** A short in two bytes for holding the block size in bytes */ |
123 private final byte[] blklen = new byte[2]; | 123 private final byte[] blklen = new byte[2]; |
124 | 124 |
125 /** Options that can be sent during the auth handshake if the server supports it */ | |
126 private HandshakeOptions handshakeOptions; | |
127 | |
125 /** | 128 /** |
126 * Constructs a new MapiSocket. | 129 * Constructs a new MapiSocket. |
127 */ | 130 */ |
128 public MapiSocket() { | 131 public MapiSocket() { |
129 con = null; | 132 con = null; |
531 } else { | 534 } else { |
532 throw new MCLParseException("Invalid byte-order: " + chaltok[4]); | 535 throw new MCLParseException("Invalid byte-order: " + chaltok[4]); |
533 } | 536 } |
534 | 537 |
535 // compose and return response | 538 // compose and return response |
536 return "BIG:" // JVM byte-order is big-endian | 539 String response = "BIG:" // JVM byte-order is big-endian |
537 + username + ":" | 540 + username + ":" |
538 + pwhash + ":" | 541 + pwhash + ":" |
539 + language + ":" | 542 + language + ":" |
540 + (database == null ? "" : database) + ":"; | 543 + (database == null ? "" : database) + ":"; |
544 if (chaltok.length > 6) { | |
545 // this ':' delimits the FILETRANS field, currently empty because we don't support it. | |
546 response += ":"; | |
547 | |
548 // if supported, send handshake options | |
549 for (String part : chaltok[6].split(",")) { | |
550 if (part.startsWith("sql=") && handshakeOptions != null) { | |
551 int level; | |
552 try { | |
553 level = Integer.parseInt(chaltok[6].substring(4)); | |
554 } catch (NumberFormatException e) { | |
555 throw new MCLParseException("Invalid handshake level: " + chaltok[6]); | |
556 } | |
557 response += handshakeOptions.formatResponse(level); | |
558 break; | |
559 } | |
560 } | |
561 // this ':' delimits the handshake options field. | |
562 response += ":"; | |
563 | |
564 } | |
565 return response; | |
541 default: | 566 default: |
542 throw new MCLException("Unsupported protocol version: " + version); | 567 throw new MCLException("Unsupported protocol version: " + version); |
543 } | 568 } |
544 } | 569 } |
545 | 570 |
683 */ | 708 */ |
684 private final void log(final String type, final String message, final boolean flush) throws IOException { | 709 private final void log(final String type, final String message, final boolean flush) throws IOException { |
685 log.write(type + System.currentTimeMillis() + ": " + message + "\n"); | 710 log.write(type + System.currentTimeMillis() + ": " + message + "\n"); |
686 if (flush) | 711 if (flush) |
687 log.flush(); | 712 log.flush(); |
713 } | |
714 | |
715 public void setHandshakeOptions(HandshakeOptions handshakeOptions) { | |
716 this.handshakeOptions = handshakeOptions; | |
717 } | |
718 | |
719 public HandshakeOptions getHandshakeOptions() { | |
720 return handshakeOptions; | |
688 } | 721 } |
689 | 722 |
690 /** | 723 /** |
691 * Inner class that is used to write data on a normal stream as a | 724 * Inner class that is used to write data on a normal stream as a |
692 * blocked stream. A call to the flush() method will write a | 725 * blocked stream. A call to the flush() method will write a |