I was trying to GET
a binary data using request
, and had something like:
var requestSettings = {
method: 'GET',
url: url,
};
request(requestSettings, function(error, response, body) {
// Use body as a binary Buffer
}
But body
was always a few bytes different from expected. After further investigation I found out that request
assumed body
is string and replaced all non-unicode bytes.
I tried to add
encoding: 'binary'
to requestSettings
but it didn't help.
How can I get the binary data?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…