使用http.get请求javascript设置标题

时间:2018-08-20 13:28:31

标签: javascript node.js http request http-headers

您好,我想设置此确切的http示例的标题

    var http = require('http');
    var request = http.get($scope.getUrl(item), function (response) {
        //something here
     };

尝试如下:

response.headers = "Range: bytes=0 - 10";

它没有按我的要求工作

1 个答案:

答案 0 :(得分:0)

尝试使用setHeader方法。像这样:

  var http = require('http');
    var request = http.get($scope.getUrl(item), function (response) {
        response.setHeader("Range", "bytes=0 - 10");
     };