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

[Node] HTTP response with a native Buffer object results gives base64 #814

Closed
yvele opened this issue Oct 25, 2016 · 3 comments
Closed

[Node] HTTP response with a native Buffer object results gives base64 #814

yvele opened this issue Oct 25, 2016 · 3 comments
Assignees
Labels

Comments

@yvele
Copy link

yvele commented Oct 25, 2016

Repro steps

context.res.body = Buffer.from("using a buffer");

PS: I also set content-type to application/json; charset=utf-8

Expected behavior

A or B?

A. Decoded buffer

Decoded buffer should be output

using a buffer

This solution is maybe the best as you are already planing to add ExpressJS style API for HTTP responses: #781 #160

B. An explicit error message

Should throw an explicit error message like a TypeError

TypeError : Response body should be string

Actual behavior

HTTP output is: dXNpbmcgYSBidWZmZXI=

Known workarounds

context.res.body = JSON.parse(Buffer.from("using a buffer"));

Related information

I'm using my own small connect adaptor for Azure Function (working like a charm) that allows me to use express and all available middlewares. That's why I found this issue.. some middlewares are directly dealing with Buffers

edit: confirmed by @mamaso that buffer should be supported

@mamaso
Copy link
Contributor

mamaso commented Oct 25, 2016

We definitely have some work to do with content negotiation in node, was just talking about this with @fabiocav yesterday. I'll play around with this scenario in express & functions and figure out a consistent behavior

@yvele
Copy link
Author

yvele commented Nov 2, 2016

With an Express adapter: https://github.com/yvele/azure-function-express no need to worry about content negotiation 😉

@yvele
Copy link
Author

yvele commented Nov 29, 2016

👍

@christopheranderson christopheranderson modified the milestone: Next - Triaged Jan 4, 2017
@ghost ghost locked as resolved and limited conversation to collaborators Jan 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants