grand CORS for json files

pull/325/head
Michael Peter Christen 5 years ago
parent 5eb0033aef
commit 053e54a2c7

@ -841,7 +841,11 @@ public class YaCyDefaultServlet extends HttpServlet {
response.setDateHeader(HeaderFramework.LAST_MODIFIED, now); response.setDateHeader(HeaderFramework.LAST_MODIFIED, now);
response.setDateHeader(HeaderFramework.EXPIRES, now); // expires now response.setDateHeader(HeaderFramework.EXPIRES, now); // expires now
} }
if (target.endsWith(".json")) {
response.setHeader(HeaderFramework.CORS_ALLOW_ORIGIN, "*");
}
if ((targetClass != null)) { if ((targetClass != null)) {
serverObjects args = new serverObjects(); serverObjects args = new serverObjects();
Enumeration<String> argNames = request.getParameterNames(); // on ssi jetty dispatcher merged local ssi query parameters Enumeration<String> argNames = request.getParameterNames(); // on ssi jetty dispatcher merged local ssi query parameters

@ -668,7 +668,7 @@ public final class HTTPDProxyHandler {
cachedResponseHeader.put(HeaderFramework.CONTENT_LENGTH, Integer.toString(0)); cachedResponseHeader.put(HeaderFramework.CONTENT_LENGTH, Integer.toString(0));
// send cached header with replaced date and added length // 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' //respondHeader(respond, "304 OK", cachedResponseHeader); // respond with 'not modified'
} else { } else {
// unconditional request: send content of cache // unconditional request: send content of cache
@ -679,7 +679,7 @@ public final class HTTPDProxyHandler {
cachedResponseHeader.put(HeaderFramework.CONTENT_LENGTH, Long.toString(cacheEntry.length)); cachedResponseHeader.put(HeaderFramework.CONTENT_LENGTH, Long.toString(cacheEntry.length));
// send cached header with replaced date and added 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' //respondHeader(respond, "203 OK", cachedResponseHeader); // respond with 'non-authoritative'
// send also the complete body now from the cache // send also the complete body now from the cache

@ -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( static final void sendRespondHeader(
final HashMap<String, Object> conProp, final HashMap<String, Object> conProp,
final OutputStream respond, final OutputStream respond,

Loading…
Cancel
Save