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

Function Test_Ctx_Range_TooManyRanges

ctx_test.go:5209–5226  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5207}
5208
5209func Test_Ctx_Range_TooManyRanges(t *testing.T) {
5210 t.Parallel()
5211 app := New(Config{MaxRanges: 2})
5212 app.Get("/", func(c Ctx) error {
5213 _, err := c.Range(10)
5214 if err != nil {
5215 return err
5216 }
5217 return c.SendString("ok")
5218 })
5219
5220 req := httptest.NewRequest(MethodGet, "http://example.com/", http.NoBody)
5221 req.Header.Set(HeaderRange, "bytes=0-1,2-3,4-5")
5222 resp, err := app.Test(req)
5223 require.NoError(t, err)
5224 require.Equal(t, StatusRequestedRangeNotSatisfiable, resp.StatusCode)
5225 require.Equal(t, "bytes */10", resp.Header.Get(HeaderContentRange))
5226}
5227
5228func Test_Ctx_Range_SuffixNormalization(t *testing.T) {
5229 t.Parallel()

Callers

nothing calls this directly

Calls 6

TestMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
RangeMethod · 0.65
SendStringMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected