WriteNotModified sends a 304 "Not Modified" status code to the client, it makes sure that the content type, the content length headers and any "ETag" are removed before the response sent. It's mostly used internally on core/router/fs.go and context methods.
()
| 3493 | // |
| 3494 | // It's mostly used internally on core/router/fs.go and context methods. |
| 3495 | func (ctx *Context) WriteNotModified() { |
| 3496 | // RFC 7232 section 4.1: |
| 3497 | // a sender SHOULD NOT generate representation metadata other than the |
| 3498 | // above listed fields unless said metadata exists for the purpose of |
| 3499 | // guiding cache updates (e.g.," Last-Modified" might be useful if the |
| 3500 | // response does not have an ETag field). |
| 3501 | h := ctx.ResponseWriter().Header() |
| 3502 | delete(h, ContentTypeHeaderKey) |
| 3503 | delete(h, ContentLengthHeaderKey) |
| 3504 | if h.Get(ETagHeaderKey) != "" { |
| 3505 | delete(h, LastModifiedHeaderKey) |
| 3506 | } |
| 3507 | ctx.StatusCode(http.StatusNotModified) |
| 3508 | } |
| 3509 | |
| 3510 | // WriteWithExpiration works like `Write` but it will check if a resource is modified, |
| 3511 | // based on the "modtime" input argument, |
no test coverage detected