Feature #319

Allow user modify response headers in Skylark

Added by Jan Dolinár almost 12 years ago. Updated almost 12 years ago.

Status:ApprovedStart date:08/28/2012
Priority:NormalDue 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");
    }
}

Skylark.diff Magnifier (2.41 KB) Jan Dolinár, 08/28/2012 09:45 PM

History

#1 Updated by Jan Dolinár almost 12 years ago

EDIT: corrected the example

#2 Updated by Miroslav Fidler almost 12 years ago

  • Status changed from Patch ready to Approved

Also available in: Atom PDF