Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

grand CORS for json files

Michael Peter Christen053e54a2c734
diff --git a/source/net/yacy/http/servlets/YaCyDefaultServlet.java b/source/net/yacy/http/servlets/YaCyDefaultServlet.java
index f01dde542..6b3e39a10 100644
--- a/source/net/yacy/http/servlets/YaCyDefaultServlet.java
+++ b/source/net/yacy/http/servlets/YaCyDefaultServlet.java
@@ -841,7 +841,11 @@ public class YaCyDefaultServlet extends HttpServlet {
response.setDateHeader(HeaderFramework.LAST_MODIFIED, now);
response.setDateHeader(HeaderFramework.EXPIRES, now); // expires now
}
-
+
+ if (target.endsWith(".json")) {
+ response.setHeader(HeaderFramework.CORS_ALLOW_ORIGIN, "*");
+ }
+
if ((targetClass != null)) {
serverObjects args = new serverObjects();
Enumeration<String> argNames = request.getParameterNames(); // on ssi jetty dispatcher merged local ssi query parameters
diff --git a/source/net/yacy/server/http/HTTPDProxyHandler.java b/source/net/yacy/server/http/HTTPDProxyHandler.java
index 832b90122..b181d687b 100644
--- a/source/net/yacy/server/http/HTTPDProxyHandler.java
+++ b/source/net/yacy/server/http/HTTPDProxyHandler.java
@@ -668,7 +668,7 @@ public final class HTTPDProxyHandler {
cachedResponseHeader.put(HeaderFramework.CONTENT_LENGTH, Integer.toString(0));
// send cached header with replaced date and added length
- HTTPDemon.sendRespondHeader(conProp,respond,clienthttpVer,304,cachedResponseHeader);
+ HTTPDemon.sendRespondHeader(conProp,respond,clienthttpVer,304,null,cachedResponseHeader);
//respondHeader(respond, "304 OK", cachedResponseHeader); // respond with 'not modified'
} else {
// unconditional request: send content of cache
@@ -679,7 +679,7 @@ public final class HTTPDProxyHandler {
cachedResponseHeader.put(HeaderFramework.CONTENT_LENGTH, Long.toString(cacheEntry.length));
// send cached header with replaced date and added length
- HTTPDemon.sendRespondHeader(conProp,respond,clienthttpVer,203,cachedResponseHeader);
+ HTTPDemon.sendRespondHeader(conProp,respond,clienthttpVer,203,null,cachedResponseHeader);
//respondHeader(respond, "203 OK", cachedResponseHeader); // respond with 'non-authoritative'
// send also the complete body now from the cache
diff --git a/source/net/yacy/server/http/HTTPDemon.java b/source/net/yacy/server/http/HTTPDemon.java
index 2245964c4..72631100a 100644
--- a/source/net/yacy/server/http/HTTPDemon.java
+++ b/source/net/yacy/server/http/HTTPDemon.java
@@ -215,16 +215,6 @@ public final class HTTPDemon {
}
}
- static final void sendRespondHeader(
- final HashMap<String, Object> conProp,
- final OutputStream respond,
- final String httpVersion,
- final int httpStatusCode,
- final ResponseHeader header
- ) throws IOException {
- sendRespondHeader(conProp,respond,httpVersion,httpStatusCode,null,header);
- }
-
static final void sendRespondHeader(
final HashMap<String, Object> conProp,
final OutputStream respond,