TL,DR; HTTP请求/响应标头(下面粘贴)中是否有任何内容阻止浏览器打开保存对话框?
我希望浏览器在从App Engine收到JSON HTTP响应时提示用户'另存为'。
HTTP POST
使用案例
HTTP POST
使用JSON在正文中发出请求。请求标题
:authority: my-app.appspot.com
:method: POST
:path: /download
:scheme: https
accept: application/json, text/plain, */*
accept-encoding: gzip, deflate, br
accept-language: en-US,en;q=0.9
cache-control: no-cache
content-length: 2030
content-type: application/json
origin: https://my-app.appspot.com
pragma: no-cache
referer: https://my-app.appspot.com/
user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
响应标题
access-control-expose-headers: Content-Disposition
cache-control: private
content-disposition: attachment;filename=export.json
content-encoding: gzip
content-length: 466
content-type: application/json
date: Thu, 07 Jun 2018 20:42:14 GMT
server: Google Frontend
status: 200
vary: Accept-Encoding
Angular Service发起请求:
@Injectable({
providedIn: 'root'
})
export class DownloadService {
constructor(private readonly http: HttpClient) {}
public download(request: DownloadRequest): Observable<DownloadResponse> {
const url: string = 'https://my-app.appspot.com/download';
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
}),
options: {
responseType: ResponseContentType.Json
}
};
return this.http.post<DownloadResponse>(url, request, httpOptions);
}
}
没有错误,但浏览器不提示用户下载。
的everythin