Skip to content

gRPC responses doesn't support setting up custom headers #128

Open
@vronin

Description

@vronin

Proposal

gRPC supports setting custom response HTTP headers.

I attempted to implement this based on an example in the README, specifically the section on setting up headers:

{
  "request" : {
    "urlPath" : "/com.example.grpc.GreetingService/greeting",
    "method" : "POST",
    "bodyPatterns" : [{
      "equalToJson" : "{ \"name\":  \"Tom\" }"
    }]
  },
  "response" : {
    "status" : 200,
    "body" : "{\n  \"greeting\": \"Hi Tom\"\n}",
    "headers" : {
      "grpc-status-name" : "OK"
    }
  }
}

I modified the headers key and value to include a custom header. While the header tag was accepted (i.e., WireMock didn't throw any errors), it doesn't appear in the response.

I reviewed the wiremock-grpc-extension codebase but couldn't locate code or tests handling this behavior. That said, I might have missed something since I'm not very familiar with the codebase.

Supporting custom headers in gRPC responses would be useful.

BTW. Please let me know if I am missing anything.

Reproduction steps

  1. Create a mapping with custom headers in the response tag.
  2. Have a client doing gRPC call (resulting in UnaryServerCall)
  3. Check the response headers on the client side.
  4. Observed headers:
    • content-type: application/grpc
    • grpc-encoding: identity
    • grpc-accept-encoding: gzip
    • grpc-status: 0

However, custom headers are not present in the response.

References

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions