|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2021 the original author or authors. |
| 2 | + * Copyright 2002-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -145,18 +145,19 @@ public String getName() {
|
145 | 145 | /**
|
146 | 146 | * Transports with no native cross-domain communication (e.g. "eventsource",
|
147 | 147 | * "htmlfile") must get a simple page from the "foreign" domain in an invisible
|
148 |
| - * iframe so that code in the iframe can run from a domain local to the SockJS |
149 |
| - * server. Since the iframe needs to load the SockJS javascript client library, |
150 |
| - * this property allows specifying where to load it from. |
| 148 | + * {@code iframe} so that code in the {@code iframe} can run from a domain |
| 149 | + * local to the SockJS server. Since the {@code iframe} needs to load the |
| 150 | + * SockJS JavaScript client library, this property allows specifying where to |
| 151 | + * load it from. |
151 | 152 | * <p>By default this is set to point to
|
152 |
| - * "<a href="https://cdn.jsdelivr.net/sockjs/1.0.0/sockjs.min.js">sockjs.min.js</a>". |
| 153 | + * <a href="https://cdn.jsdelivr.net/sockjs/1.0.0/sockjs.min.js">"https://cdn.jsdelivr.net/sockjs/1.0.0/sockjs.min.js"</a>. |
153 | 154 | * However, it can also be set to point to a URL served by the application.
|
154 | 155 | * <p>Note that it's possible to specify a relative URL in which case the URL
|
155 |
| - * must be relative to the iframe URL. For example assuming a SockJS endpoint |
156 |
| - * mapped to "/sockjs", and resulting iframe URL "/sockjs/iframe.html", then |
| 156 | + * must be relative to the {@code iframe} URL. For example assuming a SockJS endpoint |
| 157 | + * mapped to "/sockjs", and resulting {@code iframe} URL "/sockjs/iframe.html", then |
157 | 158 | * the relative URL must start with "../../" to traverse up to the location
|
158 | 159 | * above the SockJS mapping. In case of a prefix-based Servlet mapping one more
|
159 |
| - * traversal may be needed. |
| 160 | + * traversals may be needed. |
160 | 161 | */
|
161 | 162 | public void setSockJsClientLibraryUrl(String clientLibraryUrl) {
|
162 | 163 | this.clientLibraryUrl = clientLibraryUrl;
|
@@ -613,24 +614,23 @@ else if (request.getMethod() == HttpMethod.OPTIONS) {
|
613 | 614 |
|
614 | 615 | private class IframeHandler implements SockJsRequestHandler {
|
615 | 616 |
|
616 |
| - private static final String IFRAME_CONTENT = |
617 |
| - """ |
618 |
| - <!DOCTYPE html> |
619 |
| - <html> |
620 |
| - <head> |
621 |
| - <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
622 |
| - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
623 |
| - <script> |
624 |
| - document.domain = document.domain; |
625 |
| - _sockjs_onload = function(){SockJS.bootstrap_iframe();}; |
626 |
| - </script> |
627 |
| - <script src="%s"></script> |
628 |
| - </head> |
629 |
| - <body> |
630 |
| - <h2>Don't panic!</h2> |
631 |
| - <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p> |
632 |
| - </body> |
633 |
| - </html>"""; |
| 617 | + private static final String IFRAME_CONTENT = """ |
| 618 | + <!DOCTYPE html> |
| 619 | + <html> |
| 620 | + <head> |
| 621 | + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
| 622 | + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 623 | + <script> |
| 624 | + document.domain = document.domain; |
| 625 | + _sockjs_onload = function(){SockJS.bootstrap_iframe();}; |
| 626 | + </script> |
| 627 | + <script src="%s"></script> |
| 628 | + </head> |
| 629 | + <body> |
| 630 | + <h2>Don't panic!</h2> |
| 631 | + <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p> |
| 632 | + </body> |
| 633 | + </html>"""; |
634 | 634 |
|
635 | 635 | @Override
|
636 | 636 | public void handle(ServerHttpRequest request, ServerHttpResponse response) throws IOException {
|
|
0 commit comments