blob: ed6938bb6e1e996312171375b748aa249947be15 [file] [log] [blame]
Mark Slee89e2bb82007-03-01 00:20:36 +00001#
David Reissea2cba82009-03-30 21:35:00 +00002# 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 Slee89e2bb82007-03-01 00:20:36 +000019
Nobuaki Sukegawae841b3d2015-11-17 11:01:17 +090020from thrift.Thrift import TException, TType, TFrozenDict
Nobuaki Sukegawa7b545b52016-01-11 13:46:04 +090021from thrift.transport.TTransport import TTransportException
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +090022from ..compat import binary_to_str, str_to_binary
Mark Sleecde2b612006-09-03 21:13:07 +000023
Nobuaki Sukegawa299255a2016-01-06 14:52:50 +090024import six
25import sys
26from itertools import islice
27from six.moves import zip
28
Mark Slee92195ae2007-02-21 05:16:30 +000029
Bryan Duxbury69720412012-01-03 17:32:30 +000030class TProtocolException(TException):
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090031 """Custom Protocol Exception class"""
Mark Slee92195ae2007-02-21 05:16:30 +000032
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090033 UNKNOWN = 0
34 INVALID_DATA = 1
35 NEGATIVE_SIZE = 2
36 SIZE_LIMIT = 3
37 BAD_VERSION = 4
38 NOT_IMPLEMENTED = 5
39 DEPTH_LIMIT = 6
Mark Slee92195ae2007-02-21 05:16:30 +000040
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090041 def __init__(self, type=UNKNOWN, message=None):
42 TException.__init__(self, message)
43 self.type = type
Mark Slee92195ae2007-02-21 05:16:30 +000044
Mark Sleecde2b612006-09-03 21:13:07 +000045
Nobuaki Sukegawab9c859a2015-12-21 01:10:25 +090046class TProtocolBase(object):
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090047 """Base class for Thrift protocol driver."""
Mark Sleecde2b612006-09-03 21:13:07 +000048
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090049 def __init__(self, trans):
50 self.trans = trans
Mark Slee4ac459f2006-10-25 21:39:01 +000051
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090052 @staticmethod
53 def _check_length(limit, length):
54 if length < 0:
55 raise TTransportException(TTransportException.NEGATIVE_SIZE,
56 'Negative length: %d' % length)
57 if limit is not None and length > limit:
58 raise TTransportException(TTransportException.SIZE_LIMIT,
59 'Length exceeded max allowed: %d' % limit)
Nobuaki Sukegawa7b545b52016-01-11 13:46:04 +090060
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090061 def writeMessageBegin(self, name, ttype, seqid):
62 pass
Mark Sleecde2b612006-09-03 21:13:07 +000063
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090064 def writeMessageEnd(self):
65 pass
Mark Sleecde2b612006-09-03 21:13:07 +000066
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090067 def writeStructBegin(self, name):
68 pass
Mark Sleecde2b612006-09-03 21:13:07 +000069
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090070 def writeStructEnd(self):
71 pass
Mark Sleecde2b612006-09-03 21:13:07 +000072
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090073 def writeFieldBegin(self, name, ttype, fid):
74 pass
Mark Sleecde2b612006-09-03 21:13:07 +000075
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090076 def writeFieldEnd(self):
77 pass
Mark Sleecde2b612006-09-03 21:13:07 +000078
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090079 def writeFieldStop(self):
80 pass
Mark Sleecde2b612006-09-03 21:13:07 +000081
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090082 def writeMapBegin(self, ktype, vtype, size):
83 pass
Mark Sleecde2b612006-09-03 21:13:07 +000084
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090085 def writeMapEnd(self):
86 pass
Mark Sleecde2b612006-09-03 21:13:07 +000087
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090088 def writeListBegin(self, etype, size):
89 pass
Mark Sleecde2b612006-09-03 21:13:07 +000090
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090091 def writeListEnd(self):
92 pass
Mark Sleecde2b612006-09-03 21:13:07 +000093
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090094 def writeSetBegin(self, etype, size):
95 pass
Mark Sleecde2b612006-09-03 21:13:07 +000096
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +090097 def writeSetEnd(self):
98 pass
Mark Sleecde2b612006-09-03 21:13:07 +000099
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900100 def writeBool(self, bool_val):
101 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000102
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900103 def writeByte(self, byte):
104 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000105
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900106 def writeI16(self, i16):
107 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000108
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900109 def writeI32(self, i32):
110 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000111
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900112 def writeI64(self, i64):
113 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000114
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900115 def writeDouble(self, dub):
116 pass
Mark Sleec98d0502006-09-06 02:42:25 +0000117
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900118 def writeString(self, str_val):
119 self.writeBinary(str_to_binary(str_val))
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900120
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900121 def writeBinary(self, str_val):
122 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000123
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900124 def writeUtf8(self, str_val):
125 self.writeString(str_val.encode('utf8'))
Nobuaki Sukegawa397bd512016-01-06 14:43:15 +0900126
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900127 def readMessageBegin(self):
128 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000129
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900130 def readMessageEnd(self):
131 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000132
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900133 def readStructBegin(self):
134 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000135
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900136 def readStructEnd(self):
137 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000138
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900139 def readFieldBegin(self):
140 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000141
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900142 def readFieldEnd(self):
143 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000144
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900145 def readMapBegin(self):
146 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000147
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900148 def readMapEnd(self):
149 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000150
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900151 def readListBegin(self):
152 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000153
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900154 def readListEnd(self):
155 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000156
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900157 def readSetBegin(self):
158 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000159
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900160 def readSetEnd(self):
161 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000162
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900163 def readBool(self):
164 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000165
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900166 def readByte(self):
167 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000168
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900169 def readI16(self):
170 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000171
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900172 def readI32(self):
173 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000174
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900175 def readI64(self):
176 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000177
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900178 def readDouble(self):
179 pass
Mark Sleec98d0502006-09-06 02:42:25 +0000180
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900181 def readString(self):
182 return binary_to_str(self.readBinary())
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900183
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900184 def readBinary(self):
185 pass
Mark Sleecde2b612006-09-03 21:13:07 +0000186
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900187 def readUtf8(self):
188 return self.readString().decode('utf8')
Nobuaki Sukegawa397bd512016-01-06 14:43:15 +0900189
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900190 def skip(self, ttype):
Roger Meierad8154a2012-12-18 21:02:16 +0100191 if ttype == TType.STOP:
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900192 return
193 elif ttype == TType.BOOL:
194 self.readBool()
195 elif ttype == TType.BYTE:
196 self.readByte()
197 elif ttype == TType.I16:
198 self.readI16()
199 elif ttype == TType.I32:
200 self.readI32()
201 elif ttype == TType.I64:
202 self.readI64()
203 elif ttype == TType.DOUBLE:
204 self.readDouble()
205 elif ttype == TType.STRING:
206 self.readString()
207 elif ttype == TType.STRUCT:
208 name = self.readStructBegin()
209 while True:
210 (name, ttype, id) = self.readFieldBegin()
211 if ttype == TType.STOP:
212 break
213 self.skip(ttype)
214 self.readFieldEnd()
215 self.readStructEnd()
216 elif ttype == TType.MAP:
217 (ktype, vtype, size) = self.readMapBegin()
218 for i in range(size):
219 self.skip(ktype)
220 self.skip(vtype)
221 self.readMapEnd()
222 elif ttype == TType.SET:
223 (etype, size) = self.readSetBegin()
224 for i in range(size):
225 self.skip(etype)
226 self.readSetEnd()
227 elif ttype == TType.LIST:
228 (etype, size) = self.readListBegin()
229 for i in range(size):
230 self.skip(etype)
231 self.readListEnd()
Mark Sleecde2b612006-09-03 21:13:07 +0000232
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900233 # tuple of: ( 'reader method' name, is_container bool, 'writer_method' name )
234 _TTYPE_HANDLERS = (
235 (None, None, False), # 0 TType.STOP
236 (None, None, False), # 1 TType.VOID # TODO: handle void?
237 ('readBool', 'writeBool', False), # 2 TType.BOOL
238 ('readByte', 'writeByte', False), # 3 TType.BYTE and I08
239 ('readDouble', 'writeDouble', False), # 4 TType.DOUBLE
240 (None, None, False), # 5 undefined
241 ('readI16', 'writeI16', False), # 6 TType.I16
242 (None, None, False), # 7 undefined
243 ('readI32', 'writeI32', False), # 8 TType.I32
244 (None, None, False), # 9 undefined
245 ('readI64', 'writeI64', False), # 10 TType.I64
246 ('readString', 'writeString', False), # 11 TType.STRING and UTF7
247 ('readContainerStruct', 'writeContainerStruct', True), # 12 *.STRUCT
248 ('readContainerMap', 'writeContainerMap', True), # 13 TType.MAP
249 ('readContainerSet', 'writeContainerSet', True), # 14 TType.SET
250 ('readContainerList', 'writeContainerList', True), # 15 TType.LIST
251 (None, None, False), # 16 TType.UTF8 # TODO: handle utf8 types?
252 (None, None, False) # 17 TType.UTF16 # TODO: handle utf16 types?
253 )
Roger Meierf4eec7a2011-09-11 18:16:21 +0000254
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900255 def _ttype_handlers(self, ttype, spec):
256 if spec == 'BINARY':
257 if ttype != TType.STRING:
258 raise TProtocolException(type=TProtocolException.INVALID_DATA,
259 message='Invalid binary field type %d' % ttype)
260 return ('readBinary', 'writeBinary', False)
261 if sys.version_info[0] == 2 and spec == 'UTF8':
262 if ttype != TType.STRING:
263 raise TProtocolException(type=TProtocolException.INVALID_DATA,
264 message='Invalid string field type %d' % ttype)
265 return ('readUtf8', 'writeUtf8', False)
266 return self._TTYPE_HANDLERS[ttype] if ttype < len(self._TTYPE_HANDLERS) else (None, None, False)
Nobuaki Sukegawa299255a2016-01-06 14:52:50 +0900267
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900268 def _read_by_ttype(self, ttype, spec, espec):
269 reader_name, _, is_container = self._ttype_handlers(ttype, spec)
270 if reader_name is None:
271 raise TProtocolException(type=TProtocolException.INVALID_DATA,
272 message='Invalid type %d' % (ttype))
273 reader_func = getattr(self, reader_name)
274 read = (lambda: reader_func(espec)) if is_container else reader_func
275 while True:
276 yield read()
Nobuaki Sukegawabc7e4802015-11-14 19:23:27 +0900277
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900278 def readFieldByTType(self, ttype, spec):
279 return self._read_by_ttype(ttype, spec, spec).next()
Roger Meierf4eec7a2011-09-11 18:16:21 +0000280
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900281 def readContainerList(self, spec):
282 ttype, tspec, is_immutable = spec
283 (list_type, list_len) = self.readListBegin()
284 # TODO: compare types we just decoded with thrift_spec
285 elems = islice(self._read_by_ttype(ttype, spec, tspec), list_len)
286 results = (tuple if is_immutable else list)(elems)
287 self.readListEnd()
288 return results
Roger Meierf4eec7a2011-09-11 18:16:21 +0000289
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900290 def readContainerSet(self, spec):
291 ttype, tspec, is_immutable = spec
292 (set_type, set_len) = self.readSetBegin()
293 # TODO: compare types we just decoded with thrift_spec
294 elems = islice(self._read_by_ttype(ttype, spec, tspec), set_len)
295 results = (frozenset if is_immutable else set)(elems)
296 self.readSetEnd()
297 return results
Roger Meierf4eec7a2011-09-11 18:16:21 +0000298
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900299 def readContainerStruct(self, spec):
300 (obj_class, obj_spec) = spec
301 obj = obj_class()
302 obj.read(self)
303 return obj
Bryan Duxbury69720412012-01-03 17:32:30 +0000304
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900305 def readContainerMap(self, spec):
306 ktype, kspec, vtype, vspec, is_immutable = spec
307 (map_ktype, map_vtype, map_len) = self.readMapBegin()
308 # TODO: compare types we just decoded with thrift_spec and
309 # abort/skip if types disagree
310 keys = self._read_by_ttype(ktype, spec, kspec)
311 vals = self._read_by_ttype(vtype, spec, vspec)
312 keyvals = islice(zip(keys, vals), map_len)
313 results = (TFrozenDict if is_immutable else dict)(keyvals)
314 self.readMapEnd()
315 return results
Roger Meierf4eec7a2011-09-11 18:16:21 +0000316
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900317 def readStruct(self, obj, thrift_spec, is_immutable=False):
318 if is_immutable:
319 fields = {}
320 self.readStructBegin()
321 while True:
322 (fname, ftype, fid) = self.readFieldBegin()
323 if ftype == TType.STOP:
324 break
325 try:
326 field = thrift_spec[fid]
327 except IndexError:
328 self.skip(ftype)
329 else:
330 if field is not None and ftype == field[1]:
331 fname = field[2]
332 fspec = field[3]
333 val = self.readFieldByTType(ftype, fspec)
334 if is_immutable:
335 fields[fname] = val
336 else:
337 setattr(obj, fname, val)
338 else:
339 self.skip(ftype)
340 self.readFieldEnd()
341 self.readStructEnd()
342 if is_immutable:
343 return obj(**fields)
Roger Meierf4eec7a2011-09-11 18:16:21 +0000344
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900345 def writeContainerStruct(self, val, spec):
346 val.write(self)
Roger Meierf4eec7a2011-09-11 18:16:21 +0000347
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900348 def writeContainerList(self, val, spec):
349 ttype, tspec, _ = spec
350 self.writeListBegin(ttype, len(val))
351 for _ in self._write_by_ttype(ttype, val, spec, tspec):
352 pass
353 self.writeListEnd()
Roger Meierf4eec7a2011-09-11 18:16:21 +0000354
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900355 def writeContainerSet(self, val, spec):
356 ttype, tspec, _ = spec
357 self.writeSetBegin(ttype, len(val))
358 for _ in self._write_by_ttype(ttype, val, spec, tspec):
359 pass
360 self.writeSetEnd()
Roger Meierf4eec7a2011-09-11 18:16:21 +0000361
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900362 def writeContainerMap(self, val, spec):
363 ktype, kspec, vtype, vspec, _ = spec
364 self.writeMapBegin(ktype, vtype, len(val))
365 for _ in zip(self._write_by_ttype(ktype, six.iterkeys(val), spec, kspec),
366 self._write_by_ttype(vtype, six.itervalues(val), spec, vspec)):
367 pass
368 self.writeMapEnd()
Roger Meierf4eec7a2011-09-11 18:16:21 +0000369
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900370 def writeStruct(self, obj, thrift_spec):
371 self.writeStructBegin(obj.__class__.__name__)
372 for field in thrift_spec:
373 if field is None:
374 continue
375 fname = field[2]
376 val = getattr(obj, fname)
377 if val is None:
378 # skip writing out unset fields
379 continue
380 fid = field[0]
381 ftype = field[1]
382 fspec = field[3]
383 self.writeFieldBegin(fname, ftype, fid)
384 self.writeFieldByTType(ftype, val, fspec)
385 self.writeFieldEnd()
386 self.writeFieldStop()
387 self.writeStructEnd()
Roger Meierf4eec7a2011-09-11 18:16:21 +0000388
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900389 def _write_by_ttype(self, ttype, vals, spec, espec):
390 _, writer_name, is_container = self._ttype_handlers(ttype, spec)
391 writer_func = getattr(self, writer_name)
392 write = (lambda v: writer_func(v, espec)) if is_container else writer_func
393 for v in vals:
394 yield write(v)
Nobuaki Sukegawa299255a2016-01-06 14:52:50 +0900395
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900396 def writeFieldByTType(self, ttype, val, spec):
397 self._write_by_ttype(ttype, [val], spec, spec).next()
Roger Meierf4eec7a2011-09-11 18:16:21 +0000398
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900399
Konrad Grochowski93fea152014-10-02 16:29:14 +0200400def checkIntegerLimits(i, bits):
Konrad Grochowski07218672014-10-09 12:18:25 +0200401 if bits == 8 and (i < -128 or i > 127):
Konrad Grochowski93fea152014-10-02 16:29:14 +0200402 raise TProtocolException(TProtocolException.INVALID_DATA,
Konrad Grochowskid5f3be52014-10-08 15:32:21 +0200403 "i8 requires -128 <= number <= 127")
Konrad Grochowski07218672014-10-09 12:18:25 +0200404 elif bits == 16 and (i < -32768 or i > 32767):
Konrad Grochowskid5f3be52014-10-08 15:32:21 +0200405 raise TProtocolException(TProtocolException.INVALID_DATA,
406 "i16 requires -32768 <= number <= 32767")
Konrad Grochowski07218672014-10-09 12:18:25 +0200407 elif bits == 32 and (i < -2147483648 or i > 2147483647):
Konrad Grochowskid5f3be52014-10-08 15:32:21 +0200408 raise TProtocolException(TProtocolException.INVALID_DATA,
409 "i32 requires -2147483648 <= number <= 2147483647")
Konrad Grochowski07218672014-10-09 12:18:25 +0200410 elif bits == 64 and (i < -9223372036854775808 or i > 9223372036854775807):
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900411 raise TProtocolException(TProtocolException.INVALID_DATA,
412 "i64 requires -9223372036854775808 <= number <= 9223372036854775807")
Bryan Duxbury69720412012-01-03 17:32:30 +0000413
Nobuaki Sukegawa760511f2015-11-06 21:24:16 +0900414
Nobuaki Sukegawab9c859a2015-12-21 01:10:25 +0900415class TProtocolFactory(object):
Nobuaki Sukegawa10308cb2016-02-03 01:57:03 +0900416 def getProtocol(self, trans):
417 pass