pomack/thrift4go — pull request #6 by carloscm (2011-12-10 00:05:38+00:00)
Title: Use TType.ThriftTypeId in the binary protocol

I have a Thrift server (Cassandra 1.0) that is barfing on BINARY fields. I've checked other language bindings and I see it available in some, and some others not, and the ones that have it appear to be aliasing it to STRING. Example tcpdump (cut down):

good:
00000014 63 71 6c 5f 71 75 65 72 79 00 00 00 01 0b 00 01 cql_quer y.......

bad:
00000014 63 71 6c 5f 71 75 65 72 79 00 00 00 01 12 00 01 cql_quer y.......

0xb = 11, the const for STRING, and 0x12 = 18, the const for BINARY. Other language bindings are outputing 0xb for binary TTypes.

From what I gather it was also the intention for the Go library, given that the method TType.ThriftTypeId exists and does just that, but it is unused right now. I've fixed tbinary_protocol.go to make sure the Write methods call this function so BINARY gets output as STRING. Maybe some other protocol writers need it too, like the compact one, but I can't test it.