[Toss-devel-svn] SF.net SVN: toss:[1440] trunk/Toss
Status: Beta
Brought to you by:
lukaszkaiser
|
From: <luk...@us...> - 2011-05-13 23:34:02
|
Revision: 1440
http://toss.svn.sourceforge.net/toss/?rev=1440&view=rev
Author: lukaszkaiser
Date: 2011-05-13 23:33:56 +0000 (Fri, 13 May 2011)
Log Message:
-----------
Add cache expiration to http GET answers.
Modified Paths:
--------------
trunk/Toss/Server/ReqHandler.ml
trunk/Toss/WebClient/Connect.js
Modified: trunk/Toss/Server/ReqHandler.ml
===================================================================
--- trunk/Toss/Server/ReqHandler.ml 2011-05-13 23:17:33 UTC (rev 1439)
+++ trunk/Toss/Server/ReqHandler.ml 2011-05-13 23:33:56 UTC (rev 1440)
@@ -353,7 +353,7 @@
(* ------------ Http Handlers ------------ *)
-let http_msg code mimetp cookies s =
+let http_msg get code mimetp cookies s =
let get_tm s =
let t = Unix.gmtime (Unix.gettimeofday() +. s) in
let day = match t.Unix.tm_wday with
@@ -371,7 +371,12 @@
| None -> c ^ "httponly"
| Some t -> c ^ "Expires=" ^ (get_tm t) ^ "; httponly" in
let cookies_s = String.concat "\n" (List.map ck_str cookies) in
- "HTTP/1.1 " ^ code ^ "\r\n" ^
+ let expires_str = if not get then "" else
+ "Expires: " ^ (get_tm (float (40 * 24 * 3600))) ^ "\r\n" in
+ "HTTP/1.1 " ^ code ^ "\r\n" ^
+ "Date: " ^ (get_tm 0.) ^ "\r\n" ^
+ "Server: Toss\r\n" ^
+ expires_str ^
"Content-Type: " ^ mimetp ^ "\r\n" ^
(if cookies = [] then "" else cookies_s ^ "\r\n") ^
"Content-length: " ^ (string_of_int (String.length s)) ^ "\r\n\r\n" ^ s
@@ -399,8 +404,8 @@
| "js" -> "text/javascript"
| "sv" -> "image/svg+xml"
| _ -> "text/html charset=utf-8" in
- http_msg "200 OK" tp [] content
- ) else http_msg "404 NOT FOUND" "text/html charset=utf-8" []
+ http_msg true "200 OK" tp [] content
+ ) else http_msg true "404 NOT FOUND" "text/html charset=utf-8" []
("<html>\n<head><title>Toss: Page Not Found</title></head>\n" ^
"<body><p>Not found: " ^ fname_in ^ "</p></body>\n</html>")
@@ -606,7 +611,7 @@
move_play tp a.(0) a.(1) a.(2) a.(3) a.(4), []
| _ ->
"MOD_PYTHON ERROR ; Traceback: Unknown Toss Command! \n " ^ tcmd, [] in
- http_msg "200 OK" "text/html charset=utf-8" new_cookies resp
+ http_msg false "200 OK" "text/html charset=utf-8" new_cookies resp
let handle_http_msg rstate cmd head msg ck =
Modified: trunk/Toss/WebClient/Connect.js
===================================================================
--- trunk/Toss/WebClient/Connect.js 2011-05-13 23:17:33 UTC (rev 1439)
+++ trunk/Toss/WebClient/Connect.js 2011-05-13 23:33:56 UTC (rev 1440)
@@ -65,7 +65,7 @@
// Send [msg] to server and return response text.
function sync_server_msg (msg) {
var xml_request = new XMLHttpRequest ();
- xml_request.open ('POST', 'Handler.py', false);
+ xml_request.open ('POST', 'Handler', false);
xml_request.setRequestHeader ('Content-Type',
'application/x-www-form-urlencoded; charset=UTF-8');
xml_request.send (msg);
@@ -80,7 +80,7 @@
// Send [msg] to server asynchronously, ignore response text.
function async_server_msg (msg, f) {
var xml_request = new XMLHttpRequest ();
- xml_request.open ('POST', 'Handler.py', true);
+ xml_request.open ('POST', 'Handler', true);
xml_request.setRequestHeader ('Content-Type',
'application/x-www-form-urlencoded; charset=UTF-8');
xml_request.onreadystatechange = function () {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|