Skip to content

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

@artonragsdale

Description

@artonragsdale

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions