| 204 | } |
| 205 | |
| 206 | func NewHTTP2RespWriter(r *http.Request, w http.ResponseWriter, connType Type, log *zerolog.Logger) (*http2RespWriter, error) { |
| 207 | flusher, isFlusher := w.(http.Flusher) |
| 208 | if !isFlusher { |
| 209 | respWriter := &http2RespWriter{ |
| 210 | r: r.Body, |
| 211 | w: w, |
| 212 | log: log, |
| 213 | } |
| 214 | err := fmt.Errorf("%T doesn't implement http.Flusher", w) |
| 215 | respWriter.WriteErrorResponse(err) |
| 216 | return nil, err |
| 217 | } |
| 218 | |
| 219 | return &http2RespWriter{ |
| 220 | r: r.Body, |
| 221 | w: w, |
| 222 | flusher: flusher, |
| 223 | shouldFlush: connType.shouldFlush(), |
| 224 | respHeaders: make(http.Header), |
| 225 | log: log, |
| 226 | }, nil |
| 227 | } |
| 228 | |
| 229 | func (rp *http2RespWriter) AddTrailer(trailerName, trailerValue string) { |
| 230 | if !rp.statusWritten { |