admin管理员组文章数量:1356515
I'm fetching some JSON with angular as:
$http({
url: '',
method: "GET",
params: {}
}).success(function(data, status, headers, config) {
console.log(data);
}
The data it's receiving is quite large, and I'm happy to gzip the source but is there a way to gunzip it when my $http
method fetches it?
I'm fetching some JSON with angular as:
$http({
url: 'https://www.somemachine./getdata',
method: "GET",
params: {}
}).success(function(data, status, headers, config) {
console.log(data);
}
The data it's receiving is quite large, and I'm happy to gzip the source but is there a way to gunzip it when my $http
method fetches it?
1 Answer
Reset to default 6Assuming the source is already zipped, just ensure the Accept-Encoding header is set to gzip on the request:
$http.get('https://www.somemachine./getdata', { headers: { 'Accept-Encoding': 'gzip' } }
).success(function(data, status, headers, config) {
console.log(data);
});
The browser will automatically unzip it when it sees the Content-Encoding=gzip header on the response.
本文标签: javascriptCan you gunzip the contents of a get request in AngularStack Overflow
版权声明:本文标题:javascript - Can you gunzip the contents of a get request in Angular? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743971018a2570690.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论