我试图从响应标头中获取“Set-Cookie”值 . 我能够成功获得响应标头,除了一个“Set-Cookie”之外的所有键值对 . 已经尝试过针对同一问题在本论坛中提供的多种解决方案 . 以下是相同的链接:

Angular 2 - Get cookie from response

Angular 4 Unable to Get Cookies From Header Response

angular2/http get location header of 201 response

Restrictions of XMLHttpRequest's getResponseHeader()?

最后一个链接说的是这样的:“ The current state of standardizing the XMLHttpRequest API does only restrict the access to the Set-Cookie and Set-Cookie2 header fields

我正在使用Http模块处理Angular 4,而Http Module使用XMLHttpRequest作为默认后端来执行http请求 . 所以如果是这种情况,我究竟能从我的响应头中访问“Set-Cookie”值 . 我现在真的不期待迁移到HttpClient模块,因为我现在已经在多个组件中注入了Http模块 . 它将成为我的应用程序的一个非常大的变化 . 因此,如果任何人都可以提供HttpModule方面的解决方案,那将会非常有用 . 以下是我的代码:

public getReportData2(apiURL)

{      
  var headers = new Headers();
  headers.append('Content-Type', 'application/json');
  let options = new RequestOptions({ headers: headers,withCredentials:true});

  return this.http.get(apiURL,options)
  .subscribe((res:Response) => console.log(res));

}

以下是我得到的回复:

enter image description here

以下是我在控制台中可以看到的 Headers :

enter image description here

谢谢 .