MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / ProxyHTTP

Method ProxyHTTP

connection/connection_test.go:72–104  ·  view source on GitHub ↗
(
	w ResponseWriter,
	tr *tracing.TracedHTTPRequest,
	isWebsocket bool,
)

Source from the content-addressed store, hash-verified

70type mockOriginProxy struct{}
71
72func (moc *mockOriginProxy) ProxyHTTP(
73 w ResponseWriter,
74 tr *tracing.TracedHTTPRequest,
75 isWebsocket bool,
76) error {
77 req := tr.Request
78 if isWebsocket {
79 switch req.URL.Path {
80 case "/ws/echo":
81 return wsEchoEndpoint(w, req)
82 case "/ws/flaky":
83 return wsFlakyEndpoint(w, req)
84 default:
85 originRespEndpoint(w, http.StatusNotFound, []byte("ws endpoint not found"))
86 return fmt.Errorf("unknown websocket endpoint %s", req.URL.Path)
87 }
88 }
89 switch req.URL.Path {
90 case "/ok":
91 originRespEndpoint(w, http.StatusOK, []byte(http.StatusText(http.StatusOK)))
92 case "/large_file":
93 originRespEndpoint(w, http.StatusOK, testLargeResp)
94 case "/400":
95 originRespEndpoint(w, http.StatusBadRequest, []byte(http.StatusText(http.StatusBadRequest)))
96 case "/500":
97 originRespEndpoint(w, http.StatusInternalServerError, []byte(http.StatusText(http.StatusInternalServerError)))
98 case "/error":
99 return fmt.Errorf("Failed to proxy to origin")
100 default:
101 originRespEndpoint(w, http.StatusNotFound, []byte("page not found"))
102 }
103 return nil
104}
105
106func (moc *mockOriginProxy) ProxyTCP(
107 ctx context.Context,

Callers

nothing calls this directly

Calls 4

wsEchoEndpointFunction · 0.85
wsFlakyEndpointFunction · 0.85
originRespEndpointFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected