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

[tor-commits] [onionoo/master] Always set `Access-Control-Allow-Origin *` header.



commit 149244abc82a21739f7a613af0fcab21494a8569
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date:   Sat Nov 9 12:47:25 2019 +0100

    Always set `Access-Control-Allow-Origin *` header.
    
    Fixes #22062.
---
 CHANGELOG.md                                                          | 4 ++++
 .../java/org/torproject/metrics/onionoo/server/ResourceServlet.java   | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 29b57e0..ea7d2fb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # Changes in version 7.0-1.??.? - 2019-1?-??
 
+ * Minor changes
+   - Set `Access-Control-Allow-Origin *` response header for bad
+     requests, too.
+
 
 # Changes in version 7.0-1.21.0 - 2019-10-18
 
diff --git a/src/main/java/org/torproject/metrics/onionoo/server/ResourceServlet.java b/src/main/java/org/torproject/metrics/onionoo/server/ResourceServlet.java
index 0fee44b..b46c465 100644
--- a/src/main/java/org/torproject/metrics/onionoo/server/ResourceServlet.java
+++ b/src/main/java/org/torproject/metrics/onionoo/server/ResourceServlet.java
@@ -96,6 +96,8 @@ public class ResourceServlet extends HttpServlet {
       HttpServletResponseWrapper response, long receivedRequestMillis)
       throws IOException {
 
+    response.setHeader("Access-Control-Allow-Origin", "*");
+
     if (this.maintenanceMode) {
       response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
       return;
@@ -408,7 +410,6 @@ public class ResourceServlet extends HttpServlet {
         ((CACHE_MAX_TIME - indexAgeMillis)
         / CACHE_INTERVAL) * CACHE_INTERVAL);
 
-    response.setHeader("Access-Control-Allow-Origin", "*");
     response.setContentType("application/json");
     response.setCharacterEncoding("utf-8");
     response.setHeader("Cache-Control", "public, max-age="



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits