java-sdk icon indicating copy to clipboard operation
java-sdk copied to clipboard

Why can't inter service calls pass through headers?

Open lysilver opened this issue 3 years ago • 1 comments

Ask your question here

image

    Map<String, String> map = new HashMap<>(2);
    map.put("aaa", "96969");
    HttpExtension httpExtension = new HttpExtension(DaprHttp.HttpMethods.GET, null, map);
    byte[] s =
        daprClient
            .invokeMethod(appId, "api/v1/test", "", httpExtension, map, TypeRef.BYTE_ARRAY)
            .block();

throw new UnsupportedOperationException();

Is it the calling problem of my code or the original design

lysilver avatar Dec 02 '21 02:12 lysilver

@lysilver I was not able to reproduce this issue with the given details.

I modified the existing Invoke HTTP Example, InvokeClient to have the following code ...https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/invoke/http

  Map<String, String> map = new HashMap<>();
        map.put("aaa", "999991");
        HttpExtension extension = new HttpExtension(DaprHttp.HttpMethods.POST, null, map);
        byte[] response = client.invokeMethod(SERVICE_APP_ID, "say", message, extension, null,
            byte[].class).block();

On running the example I got the following output in DemoService

== APP == Server: "message one"
== APP == @ 2022-03-22 23:53:00.633 and metadata: {"user-agent":"okhttp/4.9.0","host":"127.0.0.1:3000","content-type":"application/json","content-length":"13","accept-encoding":"gzip","x-daprrequestid":"a726d8de-f81e-41ab-9f25-be0cc1294212","connection":"Keep-Alive","x-forwarded-for":"192.168.1.35","x-forwarded-host":"test.local","aaa":"999991","traceparent":"00-d58d05a944ca26a68ebe2a15dce8d2d6-778da02f4d2aa1a4-01"}

Note that aaa:999991 is present in the headers list.

Could you provide more details on where you are seeing this issue?

mukundansundar avatar Mar 22 '22 18:03 mukundansundar