You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.2 KiB

4 years ago
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var iframe_template, utils;
  4. utils = require('./utils');
  5. iframe_template = "<!DOCTYPE html>\n<html>\n<head>\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n <script src=\"{{ sockjs_url }}\"></script>\n <script>\n document.domain = document.domain;\n SockJS.bootstrap_iframe();\n </script>\n</head>\n<body>\n <h2>Don't panic!</h2>\n <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p>\n</body>\n</html>";
  6. exports.app = {
  7. iframe: function(req, res) {
  8. var content, context, k, quoted_md5;
  9. context = {
  10. '{{ sockjs_url }}': this.options.sockjs_url
  11. };
  12. content = iframe_template;
  13. for (k in context) {
  14. content = content.replace(k, context[k]);
  15. }
  16. quoted_md5 = '"' + utils.md5_hex(content) + '"';
  17. if ('if-none-match' in req.headers && req.headers['if-none-match'] === quoted_md5) {
  18. res.statusCode = 304;
  19. return '';
  20. }
  21. res.setHeader('Content-Type', 'text/html; charset=UTF-8');
  22. res.setHeader('ETag', quoted_md5);
  23. return content;
  24. }
  25. };
  26. }).call(this);