MCPcopy
hub / github.com/cloudflare/cloudflared / NewHTTP2RespWriter

Function NewHTTP2RespWriter

connection/http2.go:206–227  ·  view source on GitHub ↗
(r *http.Request, w http.ResponseWriter, connType Type, log *zerolog.Logger)

Source from the content-addressed store, hash-verified

204}
205
206func 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
229func (rp *http2RespWriter) AddTrailer(trailerName, trailerValue string) {
230 if !rp.statusWritten {

Callers 4

proxyHTTPFunction · 0.92
proxyTCPFunction · 0.92
TestPersistentConnectionFunction · 0.92
ServeHTTPMethod · 0.85

Calls 3

WriteErrorResponseMethod · 0.95
ErrorfMethod · 0.80
shouldFlushMethod · 0.80

Tested by 3

proxyHTTPFunction · 0.74
proxyTCPFunction · 0.74
TestPersistentConnectionFunction · 0.74