Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data is Getting Encoded while returning response as HTML #1880

Closed
vijay8059 opened this issue Dec 22, 2020 · 1 comment
Closed

Data is Getting Encoded while returning response as HTML #1880

vijay8059 opened this issue Dec 22, 2020 · 1 comment

Comments

@vijay8059
Copy link

🐛 Bug Report

While Returning the response as content-type : application/html data is getting encoded

To Reproduce

Set the headers
header := metadata.Pairs("X-Content-Type", "application/html")
grpc.SetHeader(ctx, header)
Steps :
rpc Create (RegId) returns (Resp);
message RegId {
string id = 1;
}

message Resp {
string response = 1;
}
Above is my proto definition, in the response i am sending the <html><b> Hey Developer </b></html> but it's retuning response as. {"response":"\u003chtml\u003e\u003cb\u003e Hey Developer \u003c/b\u003e\u003c/html\u003e"}

Expected behavior

{"response":" Hey Developer "}

And also is there is a way to return just the value as response instead of key value pair, something like this " Hey Developer "

@johanbrandhorst
Copy link
Collaborator

Looks like what you're looking for is the HTTPBody marshaler behaviour :). This is automatically enabled if you use the google.api.HttpBody type. See our documentation for an example: https://grpc-ecosystem.github.io/grpc-gateway/docs/mapping/httpbody_messages/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants