func encodeHeaders(enc *hpack.Encoder, h http.Header, keys []string) { // TODO: garbage. pool sorters like http1? hot path for 1 key? if keys == nil { keys = make([]string, 0, len(h)) for k := range h { keys = append(keys, k) } sort.Strings(keys) } for _, k := range keys { vv := h[k] k = lowerHeader(k) isTE := k == "transfer-encoding" for _, v := range vv { // TODO: more of "8.1.2.2 Connection-Specific Header Fields" if isTE && v != "trailers" { continue } enc.WriteField(hpack.HeaderField{Name: k, Value: v}) } } }
func encKV(enc *hpack.Encoder, k, v string) { if VerboseLogs { log.Printf("http2: server encoding header %q = %q", k, v) } enc.WriteField(hpack.HeaderField{Name: k, Value: v}) }