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

Method AckConnection

connection/connection.go:205–222  ·  view source on GitHub ↗

AckConnection acks an HTTP connection by sending a switch protocols status code that enables the caller to upgrade to streams.

(tracePropagation string)

Source from the content-addressed store, hash-verified

203// AckConnection acks an HTTP connection by sending a switch protocols status code that enables the caller to
204// upgrade to streams.
205func (h *HTTPResponseReadWriteAcker) AckConnection(tracePropagation string) error {
206 resp := &http.Response{
207 Status: switchingProtocolText,
208 StatusCode: http.StatusSwitchingProtocols,
209 ContentLength: -1,
210 Header: http.Header{},
211 }
212
213 if secWebsocketKey := h.req.Header.Get("Sec-WebSocket-Key"); secWebsocketKey != "" {
214 resp.Header = websocket.NewResponseHeader(h.req)
215 }
216
217 if tracePropagation != "" {
218 resp.Header.Add(tracing.CanonicalCloudflaredTracingHeader, tracePropagation)
219 }
220
221 return h.w.WriteRespHeaders(resp.StatusCode, resp.Header)
222}
223
224// localProxyConnection emulates an incoming connection to cloudflared as a net.Conn.
225// Used when handling a "hijacked" connection from connection.ResponseWriter

Callers

nothing calls this directly

Calls 4

NewResponseHeaderFunction · 0.92
GetMethod · 0.80
AddMethod · 0.65
WriteRespHeadersMethod · 0.65

Tested by

no test coverage detected