MCPcopy
hub / github.com/gofiber/fiber / Test_Proxy_Do_HTTP_Prefix_URL

Function Test_Proxy_Do_HTTP_Prefix_URL

middleware/proxy/proxy_test.go:750–775  ·  view source on GitHub ↗

go test -race -run Test_Proxy_Do_HTTP_Prefix_URL

(t *testing.T)

Source from the content-addressed store, hash-verified

748
749// go test -race -run Test_Proxy_Do_HTTP_Prefix_URL
750func Test_Proxy_Do_HTTP_Prefix_URL(t *testing.T) {
751 t.Parallel()
752
753 _, addr := createProxyTestServerIPv4(t, func(c fiber.Ctx) error {
754 return c.SendString("hello world")
755 })
756
757 app := fiber.New()
758 app.Get("/*", func(c fiber.Ctx) error {
759 path := c.OriginalURL()
760 url := strings.TrimPrefix(path, "/")
761
762 require.Equal(t, "http://"+addr, url)
763 if err := Do(c, url); err != nil {
764 return err
765 }
766 c.Response().Header.Del(fiber.HeaderServer)
767 return nil
768 })
769
770 resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/http://"+addr, http.NoBody))
771 require.NoError(t, err)
772 s, err := io.ReadAll(resp.Body)
773 require.NoError(t, err)
774 require.Equal(t, "hello world", string(s))
775}
776
777// go test -race -run Test_Proxy_Forward_Global_Client
778func Test_Proxy_Forward_Global_Client(t *testing.T) {

Callers

nothing calls this directly

Calls 9

DoFunction · 0.85
TestMethod · 0.80
SendStringMethod · 0.65
NewMethod · 0.65
GetMethod · 0.65
OriginalURLMethod · 0.65
DelMethod · 0.65
ResponseMethod · 0.65

Tested by

no test coverage detected