我把一个 html 文件放在公司的云存储上,然后在浏览器输入地址链接,我想要的是打开这个 html,但是谷歌浏览器直接把这个 html 文件下载了,并不是解析 html
为什么是下载不是打开?为什么将 html 放在服务器上就可以?有什么区别?
|  |      1songjiaxin2008      2020-09-23 15:07:06 +08:00 | 
|  |      2liyang5945      2020-09-23 15:07:33 +08:00 HTTP content-type | 
|  |      3duanzs OP 自问自答一下:有可能是协议不同,放在服务器上走的是 http,放在存储上走的是 file 协议,具体我就不懂了,欢迎大佬补充? | 
|  |      4duanzs OP | 
|  |      5Tink PRO 跟协议没啥关系,都是 http,楼上两位已经说清楚了 Content-Type:text/html ; | 
|  |      6lxk11153      2020-09-23 15:20:31 +08:00 你看看区别在哪: curl -I 'https://xhgxa.ml/index.html' | 
|  |      7duanzs OP @Tink 这是响应结果,指定 Content-Type: text/html 了,还是下载 Access-Control-Allow-Headers: DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization Access-Control-Allow-Methods: GET, POST, OPTIONS Access-Control-Allow-Origin: * Cache-Control: max-age=0 Content-Disposition: attachment; filename="test.html" Content-Encoding: gzip Content-Type: text/html Date: Wed, 23 Sep 2020 07:18:39 GMT ETag: W/"fef40692c82492577988854f508d411d" Expires: Wed, 23 Sep 2020 07:18:39 GMT Last-Modified: Wed, 23 Sep 2020 07:15:26 GMT Server: openresty Transfer-Encoding: chunked Vary: Accept-Encoding x-jss-request-id: 9338D2040B2AB5C3 | 
|  |      8duanzs OP @lxk11153 404 File not found The site configured at this address does not contain the requested file. If this is your site, make sure that the filename case matches the URL. For root URLs (like http://example.com/) you must provide an index.html file. Read the full documentation for more information about using GitHub Pages. GitHub Status — @githubstatus | 
|  |      91KN6sAqR0a57no6s      2020-09-23 15:22:39 +08:00 | 
|  |      10duanzs OP @YuxiangLuo 我不是要下载这个文件,我想打开这个文件 | 
|  |      11duanzs OP 这是我测试文件 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> 测试 </body> </html> | 
|  |      12yuzo555      2020-09-23 15:28:06 +08:00 Content-Disposition | 
|  |      131KN6sAqR0a57no6s      2020-09-23 15:29:41 +08:00 @duanzs 没法下载,你们公司的云存储服务器默认你的每个请求都是下载请求,不给你解析网页的机会。它会给每个 http 响应加上 Content-Disposition,所以你没法下载。 | 
|  |      14lxk11153      2020-09-23 15:30:02 +08:00 @duanzs #10 你看#7,你自己的响应头里带了 Content-Disposition: attachment,所以就下载了;移除它就是浏览器解析了 | 
|  |      15duanzs OP @YuxiangLuo 即便是没加这个,我也不能进行网络请求是把 | 
|  |      16lxk11153      2020-09-23 15:33:48 +08:00 |