Угловой HTTPInterceptor с вложением Content-Disposition - PullRequest
0 голосов
/ 17 октября 2018

Я пытаюсь проверить, могу ли я смоделировать веб-сервис, в который загружается файл с заголовком Content-Disposition: attachment;filename=name.txt.Вот ответ в моем перехватчике:

let header: HttpHeaders  = new HttpHeaders();
header = header.set("Content-Disposition", "attachment;filename=name.txt");
header = header.set("Content-Type", "text/plain");
header = header.set("Content-Length", "3");
return Observable.of(
  new HttpResponse<any>({
    body: "abc",
    headers: header,
    status: status.code,
    statusText: status.texte,
    url: req.url,
  }),
);

Поэтому я ожидаю, что файл с именем «name.txt», содержащий «abc», будет загружаться всякий раз, когда я вызываю веб-сервис, но ничего не загружается.Что не так?

...