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

Function TestBuildHTTPRequest

connection/quic_connection_test.go:283–510  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

281}
282
283func TestBuildHTTPRequest(t *testing.T) {
284 tests := []struct {
285 name string
286 connectRequest *pogs.ConnectRequest
287 body io.ReadCloser
288 req *http.Request
289 }{
290 {
291 name: "check if http.Request is built correctly with content length",
292 connectRequest: &pogs.ConnectRequest{
293 Dest: "http://test.com",
294 Metadata: []pogs.Metadata{
295 {
296 Key: "HttpHeader:Cf-Cloudflared-Proxy-Connection-Upgrade",
297 Val: "Websocket",
298 },
299 {
300 Key: "HttpHeader:Content-Length",
301 Val: "514",
302 },
303 {
304 Key: "HttpHeader:Another-Header",
305 Val: "Misc",
306 },
307 {
308 Key: "HttpHost",
309 Val: "cf.host",
310 },
311 {
312 Key: "HttpMethod",
313 Val: "get",
314 },
315 },
316 },
317 req: &http.Request{
318 Method: "get",
319 URL: &url.URL{
320 Scheme: "http",
321 Host: "test.com",
322 },
323 Proto: "HTTP/1.1",
324 ProtoMajor: 1,
325 ProtoMinor: 1,
326 Header: http.Header{
327 "Another-Header": []string{"Misc"},
328 "Content-Length": []string{"514"},
329 },
330 ContentLength: 514,
331 Host: "cf.host",
332 Body: io.NopCloser(&bytes.Buffer{}),
333 },
334 body: io.NopCloser(&bytes.Buffer{}),
335 },
336 {
337 name: "if content length isn't part of request headers, then it's not set",
338 connectRequest: &pogs.ConnectRequest{
339 Dest: "http://test.com",
340 Metadata: []pogs.Metadata{

Callers

nothing calls this directly

Calls 4

buildHTTPRequestFunction · 0.85
RunMethod · 0.65
ContextMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected