Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angular 5-从请求中删除默认HTTP头_Javascript_Angular_Api_Http Headers_Angular5 - Fatal编程技术网

Javascript Angular 5-从请求中删除默认HTTP头

Javascript Angular 5-从请求中删除默认HTTP头,javascript,angular,api,http-headers,angular5,Javascript,Angular,Api,Http Headers,Angular5,这里的问题是,每当我向服务器发出http post请求时。 这是我在“网络”选项卡中看到的内容 Accept: application/json, text/plain, */* Accept-Encoding: gzip, deflate, br Accept-Language: en,en-GB;q=0.9 Authorization: Bearer olxyiByY_efkTH_3WavjtTnm0GclhYws.... Connection: keep-alive Content-Typ

这里的问题是,每当我向服务器发出http post请求时。 这是我在“网络”选项卡中看到的内容

Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en,en-GB;q=0.9
Authorization: Bearer olxyiByY_efkTH_3WavjtTnm0GclhYws....
Connection: keep-alive
Content-Type: application/json
我想把它移走 接受:application/json,text/plain,/
根据我的要求。当我提出每个请求时,它会自动设置

这就是我设置标题的方式

public jwt() {

  let headers = new HttpHeaders({ 'Authorization': 'Bearer ' + currentUser.access_token,
  'x-mol-lang': 'en', 'Content-Type': 'application/json'});

  return ({ withCredentials: true, headers: headers, reportProgress: true});
} 
我正在创建一个服务,并调用jwt函数进行后期操作

  _this.http.post(_this.url, body, _this.jwtService.jwt()).subscribe();
我希望在网络选项卡中显示的输出没有**接受:application/json、text/plain、/**


我有什么办法可以完成这个动作吗?

为什么要这样做?它包括
*/*
,因此它将接受任何内容,服务器没有理由查看该标头并使用406拒绝它。对于下载api,服务器会因此抛出500错误。它产生了一个问题
返回this.http.post(_this.url,body{responseType:'text'})
@edrich13-您应该修复API,使其不会阻塞一个完美的接受头。请尝试更改HttpInterceptor。导出类拦截器实现HttpInterceptor