-
Notifications
You must be signed in to change notification settings - Fork 116
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
Omit quotes around body #32
Comments
I'm looking into this. I'll keep you posted. If you have any suggestions just let me know. |
I'm pretty sure I know what's causing this. I was naively ###
Respond to an HTTP request
###
_respond: (endpointContext, body, statusCode=200, headers) ->
# Allow cross-domain requests to be made from the browser
endpointContext.response.setHeader 'Access-Control-Allow-Origin', '*'
# Ensure that a content type is set (will be overridden if also included in given headers)
endpointContext.response.setHeader 'Content-Type', 'text/json'
##################################################################
# BUG: Only JSON Content-Type responses should be JSON.stringified
##################################################################
# Prettify JSON if configured in API
if @api.config.prettyJson
bodyAsJson = JSON.stringify body, undefined, 2
else
bodyAsJson = JSON.stringify body
# Send response
endpointContext.response.writeHead statusCode, headers
endpointContext.response.write bodyAsJson
endpointContext.response.end() |
Fix Issue #32: - Prevent non-JSON response types from being wrapped in quotes - This bug required clients to do additional parsing of non-JSON types (removing quotes and escaped characters) - Add test for checking non-JSON response Content-Type - Update change log
The commit referenced below should fix this issue. I added a basic Tinytest and it passed that test along with the rest of the suite, so everything looks good to go from my end. Would you like to test it out on your use case before I bump the version and publish this? EDIT: Just realized that I could make that test description more generic, since Restivus shouldn't wrap any non-JSON Content-Types in quotes, not just |
Fix Issue #32: - Prevent non-JSON response types from being wrapped in quotes - This bug required clients to do additional parsing of non-JSON types (removing quotes and escaped characters) - Add test for checking non-JSON response Content-Type - Update change log
I went ahead and merged this fix into |
Thanks @kahmali. Tests pass here as well. I've used "text/plain" and "text/html". PS: congrats on getting an avatar, it's nice to put a face to the name ;) |
I want to return a raw string as the response data but restivus wraps the string in double quotes.
Will produce
I've tried setting the Content-type to text/plain or text/html but I get the same type of output.
What I ultimately want to do is return a JPEG image from a custom
collection/:id/photo
route that extracts the base64-encoded image from a document.The text was updated successfully, but these errors were encountered: