MCPcopy
hub / github.com/valyala/fasthttp / TestRequestCtxIfModifiedSince

Function TestRequestCtxIfModifiedSince

server_test.go:3010–3038  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3008}
3009
3010func TestRequestCtxIfModifiedSince(t *testing.T) {
3011 t.Parallel()
3012
3013 var ctx RequestCtx
3014 var req Request
3015 ctx.Init(&req, nil, defaultLogger)
3016
3017 lastModified := time.Now().Add(-time.Hour)
3018
3019 if !ctx.IfModifiedSince(lastModified) {
3020 t.Fatal("IfModifiedSince must return true for non-existing If-Modified-Since header")
3021 }
3022
3023 ctx.Request.Header.Set("If-Modified-Since", string(AppendHTTPDate(nil, lastModified)))
3024
3025 if ctx.IfModifiedSince(lastModified) {
3026 t.Fatal("If-Modified-Since current time must return false")
3027 }
3028
3029 past := lastModified.Add(-time.Hour)
3030 if ctx.IfModifiedSince(past) {
3031 t.Fatal("If-Modified-Since past time must return false")
3032 }
3033
3034 future := lastModified.Add(time.Hour)
3035 if !ctx.IfModifiedSince(future) {
3036 t.Fatal("If-Modified-Since future time must return true")
3037 }
3038}
3039
3040func TestRequestCtxSendFileNotModified(t *testing.T) {
3041 t.Parallel()

Callers

nothing calls this directly

Calls 5

InitMethod · 0.95
IfModifiedSinceMethod · 0.95
AppendHTTPDateFunction · 0.85
AddMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…