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

Method Serve

connection/http2.go:78–97  ·  view source on GitHub ↗

Serve serves an HTTP2 server that the edge can talk to.

(ctx context.Context)

Source from the content-addressed store, hash-verified

76
77// Serve serves an HTTP2 server that the edge can talk to.
78func (c *HTTP2Connection) Serve(ctx context.Context) error {
79 go func() {
80 <-ctx.Done()
81 c.close()
82 }()
83 c.server.ServeConn(c.conn, &http2.ServeConnOpts{
84 Context: ctx,
85 Handler: c,
86 })
87
88 switch {
89 case c.controlStreamHandler.IsStopped():
90 return nil
91 case c.controlStreamErr != nil:
92 return c.controlStreamErr
93 default:
94 c.observer.log.Info().Uint8(LogFieldConnIndex, c.connIndex).Msg("Lost connection with the edge")
95 return errEdgeConnectionClosed
96 }
97}
98
99func (c *HTTP2Connection) ServeHTTP(w http.ResponseWriter, r *http.Request) {
100 c.activeRequestsWG.Add(1)

Callers 1

serveHTTP2Method · 0.95

Calls 2

closeMethod · 0.95
IsStoppedMethod · 0.65

Tested by

no test coverage detected