Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Cannot get binary data - encoding option not available in v3 as it was in v2 #105

@jonathanr24

Description

@jonathanr24

In v2 we used to be able to pass in the encoding option to get requests to have request return the data back as a Buffer instead of a string. That option is not supported in v3. Instead the docs say to set the json request option to false:

If you need to call an API that returns plain text, XML, animated GIFs etc. then set the json flag to false in your request options.

However, this option isn't even implemented, and if it were implemented it still wouldn't work.

Adding:

if (opts && opts.encoding !== undefined) {
    req.use(httpTransport.setContextProperty({
        encoding: opts.encoding
    }, 'opts'));
}

to the get method in src/httpTransport/client.ts with the option encoding set to null causes body to be returned as a Buffer instead of a string - allowing support for binary data. However, it would be great to add support in a more generic fashion for additional request options.

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