[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r11852: Fix the implementation of if-modified-since for certificates (in tor/trunk: . src/or)



Author: nickm
Date: 2007-10-10 16:28:01 -0400 (Wed, 10 Oct 2007)
New Revision: 11852

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/directory.c
Log:
 r15656@catbus:  nickm | 2007-10-10 16:23:18 -0400
 Fix the implementation of if-modified-since for certificates so that it applies to all types of certificate requests.  Note that the kind of consensus that matters already has a working if-modified-since.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r15656] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-10-10 20:13:52 UTC (rev 11851)
+++ tor/trunk/ChangeLog	2007-10-10 20:28:01 UTC (rev 11852)
@@ -31,6 +31,8 @@
     - Caches now download v3 network status documents as needed.
     - Send a 503 when low on bandwidth and a vote, consensus, or certificate
       is requested.
+    - If-modified-since is now implemented properly for all kinds of
+      certificate requests.
 
   o Minor features (network statuses):
     - Tweak the implementation of proposal 109 slightly: allow at most

Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2007-10-10 20:13:52 UTC (rev 11851)
+++ tor/trunk/src/or/directory.c	2007-10-10 20:28:01 UTC (rev 11852)
@@ -2161,7 +2161,9 @@
 
   if (!strcmpstart(url,"/tor/status-vote/current/") ||
       !strcmpstart(url,"/tor/status-vote/next/")) {
-    /*XXXX020 implement if-modified-since */
+    /* XXXX If-modified-since is only the implemented for the current
+     * consensus: that's probably fine, since it's the only vote document
+     * people fetch much.*/
     int current = 1;
     ssize_t body_len = 0;
     ssize_t estimated_len = 0;
@@ -2321,7 +2323,6 @@
   }
 
   if (!strcmpstart(url,"/tor/keys/")) {
-    /*XXXX020 implement if-modified-since */
     smartlist_t *certs = smartlist_create();
     ssize_t len = -1;
     if (!strcmp(url, "/tor/keys/all")) {
@@ -2331,8 +2332,7 @@
         if (!ds->v3_certs)
           continue;
         SMARTLIST_FOREACH(ds->v3_certs, authority_cert_t *, cert,
-                if (cert->cache_info.published_on >= if_modified_since)
-                  smartlist_add(certs, cert));
+                          smartlist_add(certs, cert));
       });
     } else if (!strcmp(url, "/tor/keys/authority")) {
       authority_cert_t *cert = get_my_v3_authority_cert();
@@ -2368,6 +2368,13 @@
       smartlist_free(certs);
       goto keys_done;
     }
+    SMARTLIST_FOREACH(certs, authority_cert_t *, c,
+      if (cert->cache_info.published_on < if_modified_since)
+        SMARTLIST_DEL_CURRENT(certs, c));
+    if (!smartlist_len(certs)) {
+      write_status_line(conn, 304, "Not modified");
+      goto keys_done;
+    }
     len = 0;
     SMARTLIST_FOREACH(certs, authority_cert_t *, c,
                       len += c->cache_info.signed_descriptor_len);