From 7c1796bf8eefd5c74dcea378f1833ce66545f496 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 11 Nov 2018 13:55:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ghttp=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- geg/net/ghttp/server/download/download.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/geg/net/ghttp/server/download/download.go b/geg/net/ghttp/server/download/download.go index f54893e57..5c1d01abb 100644 --- a/geg/net/ghttp/server/download/download.go +++ b/geg/net/ghttp/server/download/download.go @@ -8,6 +8,11 @@ import ( func main() { s := g.Server() s.BindHandler("/download", func(r *ghttp.Request){ + r.Response.Header().Set("Content-Type", "text/html;charset=utf-8"); + r.Response.Header().Set("Content-type", "application/force-download"); + r.Response.Header().Set("Content-Type", "application/octet-stream"); + r.Response.Header().Set("Accept-Ranges", "bytes"); + r.Response.Header().Set("Content-Disposition", "attachment;filename=\"下载文件名称.txt\""); r.Response.ServeFile("text.txt") }) s.SetPort(8199)