Home / Function/ Test_Ctx_Attachment() — fiber Function Reference

Test_Ctx_Attachment() — fiber Function Reference

Architecture documentation for the Test_Ctx_Attachment() function in ctx_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  d5c68048_68de_4f3c_c0a7_f9540cedb779["Test_Ctx_Attachment()"]
  7b3d4933_5ae3_f84d_ff6d_0cb34e268026["ctx_test.go"]
  d5c68048_68de_4f3c_c0a7_f9540cedb779 -->|defined in| 7b3d4933_5ae3_f84d_ff6d_0cb34e268026
  style d5c68048_68de_4f3c_c0a7_f9540cedb779 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

ctx_test.go lines 685–711

func Test_Ctx_Attachment(t *testing.T) {
	t.Parallel()
	app := New()
	c := app.AcquireCtx(&fasthttp.RequestCtx{})

	// empty
	c.Attachment()
	require.Equal(t, `attachment`, string(c.Response().Header.Peek(HeaderContentDisposition)))
	// real filename
	c.Attachment("./static/img/logo.png")
	require.Equal(t, `attachment; filename="logo.png"`, string(c.Response().Header.Peek(HeaderContentDisposition)))
	require.Equal(t, "image/png", string(c.Response().Header.Peek(HeaderContentType)))
	// filename with spaces
	c.Attachment("report 2024.txt")
	require.Equal(t, `attachment; filename="report+2024.txt"`, string(c.Response().Header.Peek(HeaderContentDisposition)))
	// filename with nested path
	c.Attachment("../docs/archive.tar.gz")
	require.Equal(t, `attachment; filename="archive.tar.gz"`, string(c.Response().Header.Peek(HeaderContentDisposition)))
	// check quoting
	c.Attachment("another document.pdf\"\r\nBla: \"fasel")
	require.Equal(t, `attachment; filename="another+document.pdf%22Bla%3A+%22fasel"`, string(c.Response().Header.Peek(HeaderContentDisposition)))

	c.Attachment("файл.txt")
	header := string(c.Response().Header.Peek(HeaderContentDisposition))
	require.Contains(t, header, `filename="файл.txt"`)
	require.Contains(t, header, `filename*=UTF-8''%D1%84%D0%B0%D0%B9%D0%BB.txt`)
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does Test_Ctx_Attachment() do?
Test_Ctx_Attachment() is a function in the fiber codebase, defined in ctx_test.go.
Where is Test_Ctx_Attachment() defined?
Test_Ctx_Attachment() is defined in ctx_test.go at line 685.

Analyze Your Own Codebase

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

Try Supermodel Free