8000 Backport PR #25039: Updated WebAgg JS to check and send request over … · matplotlib/matplotlib@66953b7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 66953b7

Browse files
ksundenmeeseeksmachine
authored andcommitted
Backport PR #25039: Updated WebAgg JS to check and send request over wss if using HTTPS
1 parent bf2af86 commit 66953b7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/matplotlib/backends/web_backend/all_figures.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
figure_div.id = "figure-div";
2525
main_div.appendChild(figure_div);
2626
var websocket_type = mpl.get_websocket_type();
27-
var websocket = new websocket_type("{{ ws_uri }}" + fig_id + "/ws");
27+
var uri = "{{ ws_uri }}" + fig_id + "/ws";
28+
if (window.location.protocol === "https:") uri = uri.replace('ws:', 'wss:')
29+
var websocket = new websocket_type(uri);
2830
var fig = new mpl.figure(fig_id, websocket, mpl_ondownload, figure_div);
2931

3032
fig.focus_on_mouseover = true;

lib/matplotlib/backends/web_backend/single_figure.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
ready(
2020
function () {
2121
var websocket_type = mpl.get_websocket_type();
22-
var websocket = new websocket_type(
23-
"{{ ws_uri }}" + {{ str(fig_id) }} + "/ws");
22+
var uri = "{{ ws_uri }}" + {{ str(fig_id) }} + "/ws";
23+
if (window.location.protocol === 'https:') uri = uri.replace('ws:', 'wss:')
24+
var websocket = new websocket_type(uri);
2425
var fig = new mpl.figure(
2526
{{ str(fig_id) }}, websocket, mpl_ondownload,
2627
document.getElementById("figure"));

0 commit comments

Comments
 (0)
0