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

Function Test_Proxy_Forward_Local_Client

middleware/proxy/proxy_test.go:809–833  ·  middleware/proxy/proxy_test.go::Test_Proxy_Forward_Local_Client

go test -race -run Test_Proxy_Forward_Local_Client

(t *testing.T)

Source from the content-addressed store, hash-verified

807
808// go test -race -run Test_Proxy_Forward_Local_Client
809func Test_Proxy_Forward_Local_Client(t *testing.T) {
810 t.Parallel()
811 ln, err := net.Listen(fiber.NetworkTCP4, "127.0.0.1:0")
812 require.NoError(t, err)
813 app := fiber.New()
814 app.Get("/test_local_client", func(c fiber.Ctx) error {
815 return c.SendString("test_local_client")
816 })
817
818 addr := ln.Addr().String()
819 app.Use(Forward("http://"+addr+"/test_local_client", &fasthttp.Client{
820 NoDefaultUserAgentHeader: true,
821 DisablePathNormalizing: true,
822
823 Dial: fasthttp.Dial,
824 }))
825 startServer(app, ln)
826
827 client := clientpkg.New()
828 resp, err := client.Get("http://" + addr)
829 require.NoError(t, err)
830 require.Equal(t, fiber.StatusOK, resp.StatusCode())
831 require.Equal(t, "test_local_client", string(resp.Body()))
832 resp.Close()
833}
834
835// go test -run Test_Proxy_WithClient_Nil_Panics
836func Test_Proxy_WithClient_Nil_Panics(t *testing.T) {

Callers

nothing calls this directly

Calls 13

GetFunction · 0.92
ForwardFunction · 0.85
startServerFunction · 0.85
ListenMethod · 0.80
AddrMethod · 0.80
NewMethod · 0.65
GetMethod · 0.65
SendStringMethod · 0.65
StringMethod · 0.65
UseMethod · 0.65
BodyMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected