页面读取不出表单,response没有数据
来源:3-9 数据协商
无谓1024
2020-05-20
func hello(w http.ResponseWriter, r *http.Request) {
if r.URL.String() =="/" {
fmt.Println("connection cone:", r.URL)
body, _ := os.Open("accept/test.html")
defer body.Close()
w.Header().Set("Content-Type","text/html")
w.Header().Set("Content-Encoding","gzip")
//w.Header().Add("X-Content-Type-Options","nosniff") 不主动预测返回的数据
//压缩
var buf bytes.Buffer
gw :=gzip.NewWriter(&buf)
defer gw.Close()
bogys ,_:=ioutil.ReadAll(body)
gw.Write(bogys)
/* //解压
data :=make([]byte,1024)
gr,_ :=gzip.NewReader(&buf)
gr.Read(data)
fmt.Println(string(data))
*/
w.Write(buf.Bytes())
}
}
func main() {
http.HandleFunc("/", hello)
http.ListenAndServe(":1024", nil)
}
写回答
1回答
-
什么叫页面读取不出表单?
032020-05-26
相似问题