Feature #319
Allow user modify response headers in Skylark
| Status: | Approved | Start date: | 08/28/2012 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | Miroslav Fidler | % Done: | 0% | |
| Category: | Wpp (web framework) | Spent time: | - | |
| Target version: | - |
Description
Skylark user has currently no way to influence the headers sent in the response. This is IMHO wrong, especially for Cache-Control header which is currently hardcoded to "no-cache".
Attached patch adds two methods, ClearHeader() and SetHeader(), providing user full control. Intended usage would be for example tweaking the caching for static resources:
SKYLARK(Favicon, "/favicon.ico") {
String icon = GetDataFile("favicon.png");
String tag = IntStr64(GetFileTime(icon).ft);
http.SetHeader("Cache-Control", "max-age=2592000");
http.SetHeader("ETag", tag);
if(http.GetHeader("if-none-match") != tag){
http.ContentType("image/png") << LoadFile(icon);
} else {
http.Response(304, "Not Modified");
}
}
History
#1 Updated by Jan Dolinár about 13 years ago
EDIT: corrected the example
#2 Updated by Miroslav Fidler about 13 years ago
- Status changed from Patch ready to Approved
