这导致从服务器发送2个DATA帧:
func(w http.ResponseWriter, r *http.Request) {
w.Write("foo")
w.(http.Flusher).Flush()
w.Write("bar")
w.(http.Flusher).Flush()
}
这导致从服务器发送1个HEADERS帧:
func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Trailer:X", "a")
w.(http.Flusher).Flush()
w.Header().Set("Trailer:Y", "b")
w.(http.Flusher).Flush()
}
有没有办法让拖车帧作为多个HEADERS帧发送而不使用framer api?
答案 0 :(得分:0)
通常只能在将任何响应发送到客户端之前设置标头(或预告片)。发送第一个非标头数据后,将不再发送标头。
// Changing the header map after a call to WriteHeader (or
// Write) has no effect unless the modified headers are
// trailers.
答案 1 :(得分:0)