[mirrorbrain-commits] r8011 - /trunk/mod_mirrorbrain/mod_mirrorbrain.c

From: <poeml_at_mirrorbrain.org>
Date: Fri, 26 Mar 2010 19:26:55 -0000
Author: poeml
Date: Fri Mar 26 20:26:54 2010
New Revision: 8011

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8011&view=rev
Log:
mod_mirrorbrain:
- A previously unhandled case: if a Metalink was requested, but there's no
  known mirror in the database, we now reply with a 404 unless some fallback
  mirrors are configured.
  With torrents and zsyncs present in Metalinks, it might also make sense to
  reply with no mirrors; I'm not 100% sure. 

Modified:
    trunk/mod_mirrorbrain/mod_mirrorbrain.c

Modified: trunk/mod_mirrorbrain/mod_mirrorbrain.c
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mod_mirrorbrain/mod_mirrorbrain.c?rev=8011&r1=8010&r2=8011&view=diff
==============================================================================
--- trunk/mod_mirrorbrain/mod_mirrorbrain.c (original)
+++ trunk/mod_mirrorbrain/mod_mirrorbrain.c Fri Mar 26 20:26:54 2010
_at_@ -1498,39 +1498,49 @@
         /* can be used with a CustomLog directive, conditionally logging these requests */
         apr_table_setn(r->subprocess_env, "MB_NOMIRROR", "1");
 
-        /* FIXME: there is an unhandled case I think: a metalink was requested,
-         * but no mirror could be found. It should probably be handled with
-         * fallback mirrors. */
-
-        if ((rep == MIRRORLIST) && apr_is_empty_array(cfg->fallbacks)) {
-            debugLog(r, cfg, "empty mirrorlist");
-            ap_set_content_type(r, "text/html; charset=ISO-8859-1");
-            ap_rputs(DOCTYPE_XHTML_1_0T
-                     "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
-                     "<head>\n"
-                     "  <title>Mirror List</title>\n", r);
-            if (scfg->mirrorlist_stylesheet) {
-                ap_rprintf(r, "  <link type=\"text/css\" rel=\"stylesheet\" href=\"%s\" />\n",
-                           scfg->mirrorlist_stylesheet);
-            }
-            ap_rputs("</head>\n\n" "<body>\n", r);
-
-            ap_rprintf(r, "  <h2>Mirrors for <a href=\"http://%s%s\">http://%s%s</a></h2>\n" 
-                       "  <br/>\n", 
-                       r->hostname, r->uri, r->hostname, r->uri);
-            /* ap_rprintf(r, "Client IP address: %s<br/>\n", clientip); */
-
-            ap_rprintf(r, "I am very sorry, but no mirror was found. <br/>\n");
-            ap_rprintf(r, "Feel free to download from the above URL.\n");
-
-            ap_rputs("</body></html>\n", r);
-            return OK;
-        } 
-        if ((rep != MIRRORLIST) && apr_is_empty_array(cfg->fallbacks)) {
-            /* deliver the file ourselves */
-            debugLog(r, cfg, "have to deliver directly");
-            return DECLINED;
-        }
+        if (apr_is_empty_array(cfg->fallbacks)) {
+
+            switch (rep) {
+            case MIRRORLIST:
+                debugLog(r, cfg, "empty mirrorlist");
+                ap_set_content_type(r, "text/html; charset=ISO-8859-1");
+                ap_rputs(DOCTYPE_XHTML_1_0T
+                         "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
+                         "<head>\n"
+                         "  <title>Mirror List</title>\n", r);
+                if (scfg->mirrorlist_stylesheet) {
+                    ap_rprintf(r, "  <link type=\"text/css\" rel=\"stylesheet\" href=\"%s\" />\n",
+                               scfg->mirrorlist_stylesheet);
+                }
+                ap_rputs("</head>\n\n" "<body>\n", r);
+
+                ap_rprintf(r, "  <h2>Mirrors for <a href=\"http://%s%s\">http://%s%s</a></h2>\n" 
+                           "  <br/>\n", 
+                           r->hostname, r->uri, r->hostname, r->uri);
+                /* ap_rprintf(r, "Client IP address: %s<br/>\n", clientip); */
+
+                ap_rprintf(r, "I am very sorry, but no mirror was found. <br/>\n");
+                ap_rprintf(r, "Feel free to download from the above URL.\n");
+
+                ap_rputs("</body></html>\n", r);
+                return OK;
+            case TORRENT:
+            case ZSYNC:
+                break;
+            case META4:
+            case METALINK:
+                debugLog(r, cfg, "would have to send empty metalink... -> 404");
+                ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, 
+                        "[mod_mirrorbrain] Can't send metalink for %s (no mirrors)", filename);
+                return HTTP_NOT_FOUND;
+            default:
+                /* deliver the file ourselves */
+                debugLog(r, cfg, "have to deliver directly");
+                return DECLINED;
+            }
+
+        }
+
     }
 
 




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Fri Mar 26 2010 - 19:26:59 GMT

This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT