All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.projectodd.sockjs.IframeHandler Maven / Gradle / Ivy

There is a newer version: 1.0.2-RELEASE
Show newest version
/**
 * Copyright (C) 2014 Red Hat, Inc, and individual contributors.
 * Copyright (C) 2011-2012 VMware, Inc.
 */

package org.projectodd.sockjs;

/**
 * Roughly correlates to sockjs-node's iframe.coffee
 */
public class IframeHandler {

    private static final String IFRAME_TEMPLATE =
            "\n" +
                    "\n" +
                    "\n" +
                    "  \n" +
                    "  \n" +
                    "  \n" +
                    "  \n" +
                    "\n" +
                    "\n" +
                    "  

Don't panic!

\n" + "

This is a SockJS hidden iframe. It's used for cross domain magic.

\n" + "\n" + ""; public DispatchFunction iframe = new DispatchFunction() { @Override public Object handle(SockJsRequest req, SockJsResponse res, Object data) throws SockJsException { String content = IFRAME_TEMPLATE.replace("{{ sockjs_url }}", server.options.sockjsUrl); String quotedMd5 = "\"" + Utils.md5Hex(content) + "\""; if (quotedMd5.equals(req.getHeader("if-none-match"))) { res.statusCode(304); return ""; } res.setHeader("Content-Type", "text/html; charset=UTF-8"); res.setHeader("ETag", quotedMd5); return content; } }; public IframeHandler(SockJsServer server) { this.server = server; } private SockJsServer server; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy