req.status(self.status, "Redirect")
req.ohead["Location"] = proto.appendurl(proto.requrl(req), self.url)
return []
+
+class unmodified(dispatch.restart):
+ def handle(self, req):
+ req.status(304, "Not Modified")
+ req.ohead["Content-Length"] = "0"
+ return []
-import inspect
-import req, dispatch, session, form, resp
+import inspect, math
+import req, dispatch, session, form, resp, proto
def wsgiwrap(callable):
def wrapper(env, startreq):
ss[i] = specslot.unbound
else:
ss[i] = val
+
+def datecheck(req, mtime):
+ if "If-Modified-Since" in req.ihead:
+ rtime = proto.phttpdate(req.ihead["If-Modified-Since"])
+ if rtime >= math.floor(mtime):
+ raise resp.unmodified()
+ req.ohead["Last-Modified"] = proto.httpdate(mtime)