You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to GET some content in 'application/pdf' format (PDF 1.4). I specify in the headers headers.Accept='application/pdf' and I get content that display an empty file in any PDF viewer but the file is not empty. Have a look at this code in lib/oauth.js:
if ($this.clientOptions.detectResponseContentType && utils.isBinaryContent(response)) {
data = new Buffer(0);
type = 1;
output = response;
} else if (response.headers['content-encoding'] === 'gzip') {
var gunzip = zlib.createGunzip();
data = new Buffer(0);
type = 2;
response.pipe(gunzip);
output = gunzip;
} else {
response.setEncoding('utf8');
data = "";
output = response;
}
$this.clientOptions.detectResponseContentType is undefined and it is not documented what it does or how to set it up anyway.
In regards to isBinaryContent function it returns false for PDF.
So it is the else what it is run, so we run this line:
response.setEncoding('utf8')
I have fixed it locally by adding this:
if ($this.clientOptions.detectResponseContentType && utils.isBinaryContent(response)) {
data = new Buffer(0);
type = 1;
output = response;
} else if (response.headers['content-encoding'] === 'gzip') {
var gunzip = zlib.createGunzip();
data = new Buffer(0);
type = 2;
response.pipe(gunzip);
output = gunzip;
} else if (headers.Accept=='application/pdf') {
data = new Buffer(0);
type = 1;
output = response;
} else {
response.setEncoding('utf8');
data = "";
output = response;
}
This is more a hack than a solution but I am not sure is PDF is binary file format and I am not sure how do you use $this.clientOptions.detectResponseContentType.
The text was updated successfully, but these errors were encountered:
I am trying to GET some content in 'application/pdf' format (PDF 1.4). I specify in the headers headers.Accept='application/pdf' and I get content that display an empty file in any PDF viewer but the file is not empty. Have a look at this code in lib/oauth.js:
if ($this.clientOptions.detectResponseContentType && utils.isBinaryContent(response)) {
data = new Buffer(0);
type = 1;
output = response;
} else if (response.headers['content-encoding'] === 'gzip') {
var gunzip = zlib.createGunzip();
data = new Buffer(0);
type = 2;
response.pipe(gunzip);
output = gunzip;
} else {
response.setEncoding('utf8');
data = "";
output = response;
}
$this.clientOptions.detectResponseContentType is undefined and it is not documented what it does or how to set it up anyway.
In regards to isBinaryContent function it returns false for PDF.
So it is the else what it is run, so we run this line:
response.setEncoding('utf8')
I have fixed it locally by adding this:
if ($this.clientOptions.detectResponseContentType && utils.isBinaryContent(response)) {
data = new Buffer(0);
type = 1;
output = response;
} else if (response.headers['content-encoding'] === 'gzip') {
var gunzip = zlib.createGunzip();
data = new Buffer(0);
type = 2;
response.pipe(gunzip);
output = gunzip;
} else if (headers.Accept=='application/pdf') {
data = new Buffer(0);
type = 1;
output = response;
} else {
response.setEncoding('utf8');
data = "";
output = response;
}
This is more a hack than a solution but I am not sure is PDF is binary file format and I am not sure how do you use $this.clientOptions.detectResponseContentType.
The text was updated successfully, but these errors were encountered: