import eliza_pb2
import google.protobuf.json_format
message = {"sentence": "I feel happy."}
message_data = google.protobuf.json_format.ParseDict(message, eliza_pb2.SayRequest())
message_data = message_data.SerializeToString()
message_length = "{:08x}".format(len(message_data)).encode("utf-8")
compressed_flag = "{:02x}".format(0).encode("utf-8")
echo -en '000000000f0a0d49206665656c2068617070792e' | curl --verbose --http2 --header "Content-Type: application/grpc+proto" --header "TE: trailers" --data-binary @- --output - https://demo.connect.build/buf.connect.demo.eliza.v1.ElizaService/Say
* Trying 35.227.208.237:443...
* Connected to demo.connect.build (35.227.208.237) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
* CAfile: /etc/ssl/cert.pem
* CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-AES256-GCM-SHA384
* ALPN: server accepted h2
* Server certificate:
* subject: CN=demo.connect.build
* start date: Apr 24 09:24:05 2023 GMT
* expire date: Jul 23 10:17:38 2023 GMT
* subjectAltName: host "demo.connect.build" matched cert's "demo.connect.build"
* issuer: C=US; O=Google Trust Services LLC; CN=GTS CA 1D4
* SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* h2h3 [:method: POST]
* h2h3 [:path: /buf.connect.demo.eliza.v1.ElizaService/Say]
* h2h3 [:scheme: https]
* h2h3 [:authority: demo.connect.build]
* h2h3 [user-agent: curl/7.86.0]
* h2h3 [accept: */*]
* h2h3 [content-type: application/grpc]
* h2h3 [te: trailers]
* h2h3 [content-length: 40]
* Using Stream ID: 1 (easy handle 0x7fe95980fc00)
> POST /buf.connect.demo.eliza.v1.ElizaService/Say HTTP/2
> Host: demo.connect.build
> user-agent: curl/7.86.0
> accept: */*
> content-type: application/grpc
> te: trailers
> content-length: 40
>
* We are completely uploaded and fine
< HTTP/2 200
< content-type: application/grpc
< grpc-accept-encoding: gzip
< trailer: Grpc-Status
< trailer: Grpc-Message
< trailer: Grpc-Status-Details-Bin
< vary: Origin
< date: Sat, 06 May 2023 17:49:38 GMT
< server: Google Frontend
< traceparent: 00-dffacc1975cead20ae1edd176a849847-b5a4abbeec7bef40-01
< x-cloud-trace-context: dffacc1975cead20ae1edd176a849847/13088775253545185088;o=1
< via: 1.1 google
< content-length: 0
< alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
<
< grpc-message: protocol error: promised 808464432 bytes in enveloped message, got 35 bytes
< grpc-status: 3
< grpc-status-details-bin: CAMSS3Byb3RvY29sIGVycm9yOiBwcm9taXNlZCA4MDg0NjQ0MzIgYnl0ZXMgaW4gZW52ZWxvcGVkIG1lc3NhZ2UsIGdvdCAzNSBieXRlcw
* Connection #0 to host demo.connect.build left intact
< grpc-message: protocol error: promised 808464432 bytes in enveloped message, got 35 bytes
< grpc-status: 3
< grpc-status-details-bin: CAMSS3Byb3RvY29sIGVycm9yOiBwcm9taXNlZCA4MDg0NjQ0MzIgYnl0ZXMgaW4gZW52ZWxvcGVkIG1lc3NhZ2UsIGdvdCAzNSBieXRlcw