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

Response body parsing fails for Phoenix.Controller.send_download/3 and plain strings #110

Open
artonragsdale opened this issue Aug 21, 2024 · 0 comments

Comments

@artonragsdale
Copy link

Hello, thanks for the wonderful library, it's been super helpful!

I have run into a couple issues with the final json parsing of the response body failing when the response contains file data for download or when a basic string is returned, like when returning a plain token without a json wrapper. I'm wondering if there is an existing workaround, or if an MR to address these issues would be useful.

For the file download endpoints, I'm using Phoenix.Controller.send_download/3. There are {"content-type", "application/zip"} and {"content-disposition", "attachment; filename=\"file_name.zip\""} headers that could potentially be used to identify file payloads.

For the plain string, I was able to work around it by adding escaped quotes like so "\"token\"", but it seems like the library should be able to handle basic strings in the body. We could use the JSON.encode function without the exclamation and then if the error tuple is returned, skip the prettify step and let it be a regular binary, or something along those lines.

Thanks!

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

1 participant