• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1## Languages known issues
2
3### Python
4
5- Assert the type required in your server/client since python is able to receive `Bytes array` or `utf8 strings`.
6
7```python
8def SayHello(self, request, context):
9    # request might be a byte array or a utf8 string
10
11    r = HelloRequest.HelloRequest().GetRootAs(request, 0)
12    reply = "Unknown"
13    if r.Name():
14        reply = r.Name()
15    # Issues might happen if type checking isnt present.
16    # thus encoding it as a `reply.decode('UTF-8')`
17    return build_reply("welcome " + reply.decode('UTF-8'))
18
19```
20
21This can be prevented by making sure all the requests coming to/from python are `Bytes array`
22
23```python
24def say_hello(stub, builder):
25    hello_request = bytes(builder.Output())
26    reply = stub.SayHello(hello_request)
27    r = HelloReply.HelloReply.GetRootAs(reply)
28    print(r.Message())
29```
30
31### Go
32
33- Always requires the `content-type` of the payload to be set to `application/grpc+flatbuffers`
34
35example: `.SayHello(ctx, b, grpc.CallContentSubtype("flatbuffers"))`