Home / Function/ Test_Request_Body_With_Server() — fiber Function Reference

Test_Request_Body_With_Server() — fiber Function Reference

Architecture documentation for the Test_Request_Body_With_Server() function in request_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  8540130b_4371_50b7_8e01_644ac50a7ad2["Test_Request_Body_With_Server()"]
  3cffa885_3458_eedf_a1f5_10f9dd0f3622["request_test.go"]
  8540130b_4371_50b7_8e01_644ac50a7ad2 -->|defined in| 3cffa885_3458_eedf_a1f5_10f9dd0f3622
  38e52c61_5ac3_b644_3e5a_c2bab7537a28["checkFormFile()"]
  8540130b_4371_50b7_8e01_644ac50a7ad2 -->|calls| 38e52c61_5ac3_b644_3e5a_c2bab7537a28
  style 8540130b_4371_50b7_8e01_644ac50a7ad2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

client/request_test.go lines 1185–1395

func Test_Request_Body_With_Server(t *testing.T) {
	t.Parallel()

	t.Run("json body", func(t *testing.T) {
		t.Parallel()
		testRequest(t,
			func(c fiber.Ctx) error {
				require.Equal(t, "application/json", string(c.Request().Header.ContentType()))
				return c.SendString(string(c.Request().Body()))
			},
			func(agent *Request) {
				agent.SetJSON(map[string]string{
					"success": "hello",
				})
			},
			"{\"success\":\"hello\"}",
		)
	})

	t.Run("xml body", func(t *testing.T) {
		t.Parallel()
		testRequest(t,
			func(c fiber.Ctx) error {
				require.Equal(t, "application/xml", string(c.Request().Header.ContentType()))
				return c.SendString(string(c.Request().Body()))
			},
			func(agent *Request) {
				type args struct {
					Content string `xml:"content"`
				}
				agent.SetXML(args{
					Content: "hello",
				})
			},
			"<args><content>hello</content></args>",
		)
	})

	t.Run("cbor body", func(t *testing.T) {
		t.Parallel()
		testRequest(t,
			func(c fiber.Ctx) error {
				require.Equal(t, "application/cbor", string(c.Request().Header.ContentType()))
				return c.SendString(string(c.Request().Body()))
			},
			func(agent *Request) {
				type args struct {
					Content string `cbor:"content"`
				}
				agent.SetCBOR(args{
					Content: "hello",
				})
			},
			"\xa1gcontentehello",
		)
	})

	t.Run("formdata", func(t *testing.T) {
		t.Parallel()
		testRequest(t,
			func(c fiber.Ctx) error {
				require.Equal(t, fiber.MIMEApplicationForm, string(c.Request().Header.ContentType()))
				return c.Send([]byte("foo=" + c.FormValue("foo") + "&bar=" + c.FormValue("bar") + "&fiber=" + c.FormValue("fiber")))
			},
			func(agent *Request) {
				agent.SetFormData("foo", "bar").
					SetFormDataWithMap(map[string]string{
						"bar":   "baz",
						"fiber": "fast",
					})
			},
			"foo=bar&bar=baz&fiber=fast")
	})

	t.Run("multipart form", func(t *testing.T) {
		t.Parallel()

		app, ln, start := createHelperServer(t)
		app.Post("/", func(c fiber.Ctx) error {
			require.Equal(t, "multipart/form-data; boundary=myBoundary", c.Get(fiber.HeaderContentType))

Domain

Subdomains

Frequently Asked Questions

What does Test_Request_Body_With_Server() do?
Test_Request_Body_With_Server() is a function in the fiber codebase, defined in client/request_test.go.
Where is Test_Request_Body_With_Server() defined?
Test_Request_Body_With_Server() is defined in client/request_test.go at line 1185.
What does Test_Request_Body_With_Server() call?
Test_Request_Body_With_Server() calls 1 function(s): checkFormFile.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free