/* HTTP request */
struct http *http;
+ time_t t_req;
+ time_t t_resp;
+
unsigned handling;
TAILQ_ENTRY(sess) list;
#endif
/* rfc2616.c */
-time_t RFC2616_Ttl(struct http *hp, time_t, time_t);
+int RFC2616_cache_policy(struct sess *sp, struct http *hp);
void *fd_token;
struct http *hp;
char *b;
- time_t t_req, t_resp;
int body;
sp->obj->xid = sp->xid;
http_BuildSbuf(fd, 1, w->sb, sp->http);
i = write(fd, sbuf_data(w->sb), sbuf_len(w->sb));
assert(i == sbuf_len(w->sb));
- time(&t_req);
+ time(&sp->t_req);
/* XXX: copy any contents */
*/
http_RecvHead(hp, fd, w->eb, NULL, NULL);
event_base_loop(w->eb, 0);
- time(&t_resp);
+ time(&sp->t_resp);
http_Dissect(hp, fd, 2);
- switch (http_GetStatus(hp)) {
- case 200:
- case 301:
- /* XXX: fill in object from headers */
- sp->obj->valid = 1;
- sp->obj->cacheable = 1;
- body = 1;
- break;
- case 304:
- /* XXX: fill in object from headers */
- sp->obj->valid = 1;
- sp->obj->cacheable = 1;
- body = 0;
- break;
- default:
- body = 0;
- break;
- }
-
- sp->obj->ttl = RFC2616_Ttl(hp, t_req, t_resp);
- if (sp->obj->ttl == 0) {
- sp->obj->cacheable = 0;
- }
+ body = RFC2616_cache_policy(sp, hp);
VCL_fetch_method(sp);
#include "cache.h"
#include "libvarnish.h"
#include "heritage.h"
-
/*--------------------------------------------------------------------
* From RFC2616, 13.2.3 Age Calculations
*
*
*/
-time_t
+static time_t
RFC2616_Ttl(struct http *hp, time_t t_req, time_t t_resp)
{
time_t h_date = 0, h_expires = 0, h_age = 0;
return (ttl);
}
+
+int
+RFC2616_cache_policy(struct sess *sp, struct http *hp)
+{
+ int body = 0;
+
+ /*
+ * Initial cacheability determination per [RFC2616, 13.4]
+ * We do not support ranges yet, so 206 is out.
+ */
+ switch (http_GetStatus(hp)) {
+ case 200: /* OK */
+ sp->obj->valid = 1;
+ case 203: /* Non-Authoritative Information */
+ case 300: /* Multiple Choices */
+ case 301: /* Moved Permanently */
+ case 410: /* Gone */
+ sp->obj->cacheable = 1;
+ body = 1;
+ break;
+ default:
+ sp->obj->cacheable = 0;
+ body = 0;
+ break;
+ }
+
+ sp->obj->ttl = RFC2616_Ttl(hp, sp->t_req, sp->t_resp);
+ if (sp->obj->ttl == 0) {
+ sp->obj->cacheable = 0;
+ }
+
+ return (body);
+
+}
+