Skip to content
This repository has been 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

Open
jonathanr24 opened this issue Dec 19, 2019 · 0 comments

Comments

@jonathanr24
Copy link

jonathanr24 commented Dec 19, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant