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

Function Test_Proxy_Forward_Global_Client

middleware/proxy/proxy_test.go:778–806  ·  view source on GitHub ↗

go test -race -run Test_Proxy_Forward_Global_Client

(t *testing.T)

Source from the content-addressed store, hash-verified

776
777// go test -race -run Test_Proxy_Forward_Global_Client
778func Test_Proxy_Forward_Global_Client(t *testing.T) {
779 restoreGlobalProxyClient(t)
780 ln, err := net.Listen(fiber.NetworkTCP4, "127.0.0.1:0")
781 require.NoError(t, err)
782 WithClient(&fasthttp.Client{
783 NoDefaultUserAgentHeader: true,
784 DisablePathNormalizing: true,
785 MaxConnsPerHost: 123,
786 })
787 loadedClient := client.Load()
788 require.NotNil(t, loadedClient)
789 require.Equal(t, 123, loadedClient.MaxConnsPerHost)
790
791 app := fiber.New()
792 app.Get("/test_global_client", func(c fiber.Ctx) error {
793 return c.SendString("test_global_client")
794 })
795
796 addr := ln.Addr().String()
797 app.Use(Forward("http://" + addr + "/test_global_client"))
798 startServer(app, ln)
799
800 client := clientpkg.New()
801 resp, err := client.Get("http://" + addr)
802 require.NoError(t, err)
803 require.Equal(t, fiber.StatusOK, resp.StatusCode())
804 require.Equal(t, "test_global_client", string(resp.Body()))
805 resp.Close()
806}
807
808// go test -race -run Test_Proxy_Forward_Local_Client
809func Test_Proxy_Forward_Local_Client(t *testing.T) {

Callers

nothing calls this directly

Calls 15

GetFunction · 0.92
restoreGlobalProxyClientFunction · 0.85
WithClientFunction · 0.85
ForwardFunction · 0.85
startServerFunction · 0.85
ListenMethod · 0.80
AddrMethod · 0.80
LoadMethod · 0.65
NewMethod · 0.65
GetMethod · 0.65
SendStringMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected