Mark Slee | 89e2bb8 | 2007-03-01 00:20:36 +0000 | [diff] [blame] | 1 | # |
David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 2 | # Licensed to the Apache Software Foundation (ASF) under one |
| 3 | # or more contributor license agreements. See the NOTICE file |
| 4 | # distributed with this work for additional information |
| 5 | # regarding copyright ownership. The ASF licenses this file |
| 6 | # to you under the Apache License, Version 2.0 (the |
| 7 | # "License"); you may not use this file except in compliance |
| 8 | # with the License. You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, |
| 13 | # software distributed under the License is distributed on an |
| 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | # KIND, either express or implied. See the License for the |
| 16 | # specific language governing permissions and limitations |
| 17 | # under the License. |
| 18 | # |
Mark Slee | 89e2bb8 | 2007-03-01 00:20:36 +0000 | [diff] [blame] | 19 | |
James E. King III | e44f6a9 | 2019-02-07 17:11:21 -0500 | [diff] [blame] | 20 | from .TProtocol import TType, TProtocolBase, TProtocolException, TProtocolFactory |
bwangelme | 58000cc | 2023-11-06 12:21:38 +0800 | [diff] [blame] | 21 | from ..compat import binary_to_str |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 22 | from struct import pack, unpack |
| 23 | |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 24 | |
Bryan Duxbury | 6972041 | 2012-01-03 17:32:30 +0000 | [diff] [blame] | 25 | class TBinaryProtocol(TProtocolBase): |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 26 | """Binary implementation of the Thrift protocol driver.""" |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 27 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 28 | # NastyHaxx. Python 2.4+ on 32-bit machines forces hex constants to be |
| 29 | # positive, converting this into a long. If we hardcode the int value |
| 30 | # instead it'll stay in 32 bit-land. |
Mark Slee | 9b36ef3 | 2007-10-02 04:44:48 +0000 | [diff] [blame] | 31 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 32 | # VERSION_MASK = 0xffff0000 |
| 33 | VERSION_MASK = -65536 |
Mark Slee | 9b36ef3 | 2007-10-02 04:44:48 +0000 | [diff] [blame] | 34 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 35 | # VERSION_1 = 0x80010000 |
| 36 | VERSION_1 = -2147418112 |
Mark Slee | 9b36ef3 | 2007-10-02 04:44:48 +0000 | [diff] [blame] | 37 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 38 | TYPE_MASK = 0x000000ff |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 39 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 40 | def __init__(self, trans, strictRead=False, strictWrite=True, **kwargs): |
| 41 | TProtocolBase.__init__(self, trans) |
| 42 | self.strictRead = strictRead |
| 43 | self.strictWrite = strictWrite |
| 44 | self.string_length_limit = kwargs.get('string_length_limit', None) |
| 45 | self.container_length_limit = kwargs.get('container_length_limit', None) |
Nobuaki Sukegawa | 7b545b5 | 2016-01-11 13:46:04 +0900 | [diff] [blame] | 46 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 47 | def _check_string_length(self, length): |
| 48 | self._check_length(self.string_length_limit, length) |
Nobuaki Sukegawa | 7b545b5 | 2016-01-11 13:46:04 +0900 | [diff] [blame] | 49 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 50 | def _check_container_length(self, length): |
| 51 | self._check_length(self.container_length_limit, length) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 52 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 53 | def writeMessageBegin(self, name, type, seqid): |
| 54 | if self.strictWrite: |
| 55 | self.writeI32(TBinaryProtocol.VERSION_1 | type) |
| 56 | self.writeString(name) |
| 57 | self.writeI32(seqid) |
| 58 | else: |
| 59 | self.writeString(name) |
| 60 | self.writeByte(type) |
| 61 | self.writeI32(seqid) |
Mark Slee | 4ac459f | 2006-10-25 21:39:01 +0000 | [diff] [blame] | 62 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 63 | def writeMessageEnd(self): |
| 64 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 65 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 66 | def writeStructBegin(self, name): |
| 67 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 68 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 69 | def writeStructEnd(self): |
| 70 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 71 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 72 | def writeFieldBegin(self, name, type, id): |
| 73 | self.writeByte(type) |
| 74 | self.writeI16(id) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 75 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 76 | def writeFieldEnd(self): |
| 77 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 78 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 79 | def writeFieldStop(self): |
| 80 | self.writeByte(TType.STOP) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 81 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 82 | def writeMapBegin(self, ktype, vtype, size): |
| 83 | self.writeByte(ktype) |
| 84 | self.writeByte(vtype) |
| 85 | self.writeI32(size) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 86 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 87 | def writeMapEnd(self): |
| 88 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 89 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 90 | def writeListBegin(self, etype, size): |
| 91 | self.writeByte(etype) |
| 92 | self.writeI32(size) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 93 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 94 | def writeListEnd(self): |
| 95 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 96 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 97 | def writeSetBegin(self, etype, size): |
| 98 | self.writeByte(etype) |
| 99 | self.writeI32(size) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 100 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 101 | def writeSetEnd(self): |
| 102 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 103 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 104 | def writeBool(self, bool): |
| 105 | if bool: |
| 106 | self.writeByte(1) |
| 107 | else: |
| 108 | self.writeByte(0) |
David Reiss | 382fc30 | 2007-08-25 18:01:30 +0000 | [diff] [blame] | 109 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 110 | def writeByte(self, byte): |
| 111 | buff = pack("!b", byte) |
| 112 | self.trans.write(buff) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 113 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 114 | def writeI16(self, i16): |
| 115 | buff = pack("!h", i16) |
| 116 | self.trans.write(buff) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 117 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 118 | def writeI32(self, i32): |
| 119 | buff = pack("!i", i32) |
| 120 | self.trans.write(buff) |
David Reiss | 382fc30 | 2007-08-25 18:01:30 +0000 | [diff] [blame] | 121 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 122 | def writeI64(self, i64): |
| 123 | buff = pack("!q", i64) |
| 124 | self.trans.write(buff) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 125 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 126 | def writeDouble(self, dub): |
| 127 | buff = pack("!d", dub) |
| 128 | self.trans.write(buff) |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 129 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 130 | def writeBinary(self, str): |
| 131 | self.writeI32(len(str)) |
| 132 | self.trans.write(str) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 133 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 134 | def readMessageBegin(self): |
| 135 | sz = self.readI32() |
| 136 | if sz < 0: |
| 137 | version = sz & TBinaryProtocol.VERSION_MASK |
| 138 | if version != TBinaryProtocol.VERSION_1: |
| 139 | raise TProtocolException( |
| 140 | type=TProtocolException.BAD_VERSION, |
| 141 | message='Bad version in readMessageBegin: %d' % (sz)) |
| 142 | type = sz & TBinaryProtocol.TYPE_MASK |
| 143 | name = self.readString() |
| 144 | seqid = self.readI32() |
| 145 | else: |
| 146 | if self.strictRead: |
| 147 | raise TProtocolException(type=TProtocolException.BAD_VERSION, |
| 148 | message='No protocol version header') |
bwangelme | 58000cc | 2023-11-06 12:21:38 +0800 | [diff] [blame] | 149 | name = binary_to_str(self.trans.readAll(sz)) |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 150 | type = self.readByte() |
| 151 | seqid = self.readI32() |
| 152 | return (name, type, seqid) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 153 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 154 | def readMessageEnd(self): |
| 155 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 156 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 157 | def readStructBegin(self): |
| 158 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 159 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 160 | def readStructEnd(self): |
| 161 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 162 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 163 | def readFieldBegin(self): |
| 164 | type = self.readByte() |
| 165 | if type == TType.STOP: |
| 166 | return (None, type, 0) |
| 167 | id = self.readI16() |
| 168 | return (None, type, id) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 169 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 170 | def readFieldEnd(self): |
| 171 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 172 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 173 | def readMapBegin(self): |
| 174 | ktype = self.readByte() |
| 175 | vtype = self.readByte() |
| 176 | size = self.readI32() |
| 177 | self._check_container_length(size) |
| 178 | return (ktype, vtype, size) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 179 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 180 | def readMapEnd(self): |
| 181 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 182 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 183 | def readListBegin(self): |
| 184 | etype = self.readByte() |
| 185 | size = self.readI32() |
| 186 | self._check_container_length(size) |
| 187 | return (etype, size) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 188 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 189 | def readListEnd(self): |
| 190 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 191 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 192 | def readSetBegin(self): |
| 193 | etype = self.readByte() |
| 194 | size = self.readI32() |
| 195 | self._check_container_length(size) |
| 196 | return (etype, size) |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 197 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 198 | def readSetEnd(self): |
| 199 | pass |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 200 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 201 | def readBool(self): |
| 202 | byte = self.readByte() |
| 203 | if byte == 0: |
| 204 | return False |
| 205 | return True |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 206 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 207 | def readByte(self): |
| 208 | buff = self.trans.readAll(1) |
| 209 | val, = unpack('!b', buff) |
| 210 | return val |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 211 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 212 | def readI16(self): |
| 213 | buff = self.trans.readAll(2) |
| 214 | val, = unpack('!h', buff) |
| 215 | return val |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 216 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 217 | def readI32(self): |
| 218 | buff = self.trans.readAll(4) |
| 219 | val, = unpack('!i', buff) |
| 220 | return val |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 221 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 222 | def readI64(self): |
| 223 | buff = self.trans.readAll(8) |
| 224 | val, = unpack('!q', buff) |
| 225 | return val |
Mark Slee | cde2b61 | 2006-09-03 21:13:07 +0000 | [diff] [blame] | 226 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 227 | def readDouble(self): |
| 228 | buff = self.trans.readAll(8) |
| 229 | val, = unpack('!d', buff) |
| 230 | return val |
Mark Slee | c98d050 | 2006-09-06 02:42:25 +0000 | [diff] [blame] | 231 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 232 | def readBinary(self): |
| 233 | size = self.readI32() |
| 234 | self._check_string_length(size) |
| 235 | s = self.trans.readAll(size) |
| 236 | return s |
Mark Slee | 4ac459f | 2006-10-25 21:39:01 +0000 | [diff] [blame] | 237 | |
David Reiss | 382fc30 | 2007-08-25 18:01:30 +0000 | [diff] [blame] | 238 | |
James E. King III | e44f6a9 | 2019-02-07 17:11:21 -0500 | [diff] [blame] | 239 | class TBinaryProtocolFactory(TProtocolFactory): |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 240 | def __init__(self, strictRead=False, strictWrite=True, **kwargs): |
| 241 | self.strictRead = strictRead |
| 242 | self.strictWrite = strictWrite |
| 243 | self.string_length_limit = kwargs.get('string_length_limit', None) |
| 244 | self.container_length_limit = kwargs.get('container_length_limit', None) |
Mark Slee | 808454e | 2007-06-20 21:51:57 +0000 | [diff] [blame] | 245 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 246 | def getProtocol(self, trans): |
| 247 | prot = TBinaryProtocol(trans, self.strictRead, self.strictWrite, |
| 248 | string_length_limit=self.string_length_limit, |
| 249 | container_length_limit=self.container_length_limit) |
| 250 | return prot |
David Reiss | 382fc30 | 2007-08-25 18:01:30 +0000 | [diff] [blame] | 251 | |
| 252 | |
| 253 | class TBinaryProtocolAccelerated(TBinaryProtocol): |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 254 | """C-Accelerated version of TBinaryProtocol. |
David Reiss | 382fc30 | 2007-08-25 18:01:30 +0000 | [diff] [blame] | 255 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 256 | This class does not override any of TBinaryProtocol's methods, |
| 257 | but the generated code recognizes it directly and will call into |
| 258 | our C module to do the encoding, bypassing this object entirely. |
| 259 | We inherit from TBinaryProtocol so that the normal TBinaryProtocol |
| 260 | encoding can happen if the fastbinary module doesn't work for some |
| 261 | reason. (TODO(dreiss): Make this happen sanely in more cases.) |
Nobuaki Sukegawa | 6525f6a | 2016-02-11 13:58:39 +0900 | [diff] [blame] | 262 | To disable this behavior, pass fallback=False constructor argument. |
David Reiss | 382fc30 | 2007-08-25 18:01:30 +0000 | [diff] [blame] | 263 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 264 | In order to take advantage of the C module, just use |
| 265 | TBinaryProtocolAccelerated instead of TBinaryProtocol. |
David Reiss | 382fc30 | 2007-08-25 18:01:30 +0000 | [diff] [blame] | 266 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 267 | NOTE: This code was contributed by an external developer. |
| 268 | The internal Thrift team has reviewed and tested it, |
| 269 | but we cannot guarantee that it is production-ready. |
| 270 | Please feel free to report bugs and/or success stories |
| 271 | to the public mailing list. |
| 272 | """ |
| 273 | pass |
David Reiss | 382fc30 | 2007-08-25 18:01:30 +0000 | [diff] [blame] | 274 | |
Nobuaki Sukegawa | 6525f6a | 2016-02-11 13:58:39 +0900 | [diff] [blame] | 275 | def __init__(self, *args, **kwargs): |
| 276 | fallback = kwargs.pop('fallback', True) |
| 277 | super(TBinaryProtocolAccelerated, self).__init__(*args, **kwargs) |
| 278 | try: |
| 279 | from thrift.protocol import fastbinary |
| 280 | except ImportError: |
| 281 | if not fallback: |
| 282 | raise |
| 283 | else: |
| 284 | self._fast_decode = fastbinary.decode_binary |
| 285 | self._fast_encode = fastbinary.encode_binary |
| 286 | |
David Reiss | 382fc30 | 2007-08-25 18:01:30 +0000 | [diff] [blame] | 287 | |
James E. King III | e44f6a9 | 2019-02-07 17:11:21 -0500 | [diff] [blame] | 288 | class TBinaryProtocolAcceleratedFactory(TProtocolFactory): |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 289 | def __init__(self, |
| 290 | string_length_limit=None, |
Nobuaki Sukegawa | 6525f6a | 2016-02-11 13:58:39 +0900 | [diff] [blame] | 291 | container_length_limit=None, |
| 292 | fallback=True): |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 293 | self.string_length_limit = string_length_limit |
| 294 | self.container_length_limit = container_length_limit |
Nobuaki Sukegawa | 6525f6a | 2016-02-11 13:58:39 +0900 | [diff] [blame] | 295 | self._fallback = fallback |
Nobuaki Sukegawa | 7b545b5 | 2016-01-11 13:46:04 +0900 | [diff] [blame] | 296 | |
Nobuaki Sukegawa | 10308cb | 2016-02-03 01:57:03 +0900 | [diff] [blame] | 297 | def getProtocol(self, trans): |
| 298 | return TBinaryProtocolAccelerated( |
| 299 | trans, |
| 300 | string_length_limit=self.string_length_limit, |
Nobuaki Sukegawa | 6525f6a | 2016-02-11 13:58:39 +0900 | [diff] [blame] | 301 | container_length_limit=self.container_length_limit, |
| 302 | fallback=self._fallback) |