httpyac icon indicating copy to clipboard operation
httpyac copied to clipboard

grpc response cannot be decoded

Open yangchnet opened this issue 5 months ago • 0 comments

I have a grpc request:

GRPC 127.0.0.1:8090/ListenerDiscoveryService/FetchListeners

{
    "node": {
        "id": "xxx",
        "metadata": {
            "type": "proxy"
        }
    },
    "type_url": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment"
}

This is a steam rpc request to envoy xds-server,its definition can be found here: https://github.com/envoyproxy/data-plane-api/blob/main/envoy/service/listener/v3/lds.proto

The response of this request:

{
  "versionInfo": "2024-09-20T19:59:36+08:00/138",
  "resources": [
    {
      "type_url": "type.googleapis.com/envoy.config.listener.v3.Listener",
      "value": {
        "type": "Buffer",
        "data": [
          10,
          7,
          115,
          117,
          45,
          116,
          101,
          ...
         ]
      }
    },
}     

When I use postman to request, it returns the following:

{
    "resources": [
        {
            "type_url": "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment",
            "value": "ChdvdXRib3VuZHwzMDAwfHx0ZXN0MDYyOQ=="
        }
     ]
}

I tried decoding it with a script but I got gibberish:

{{+after

    const jsonData = JSON.parse(response.body);
    // console.info(jsonData.resources[0].value.data)

    jsonData.resources.forEach(resource => {
        const decodedValue = Buffer.from(resource.value.data, 'base64').toString('utf8');
        resource.value = decodedValue;
        console.info(decodedValue);
    });
    
}}

console log:

INFO: 
owt.pdl.test

241.0.0.47�	��
-envoy.filters.network.http_connection_manager"�

How can I turn it into a readable json?

yangchnet avatar Sep 20 '24 13:09 yangchnet