(backend_addr: string)
| 354 | * is_http_backend('http://localhost:8080/io').then(function(http_backend){ }); |
| 355 | * */ |
| 356 | export function is_http_backend(backend_addr: string) { |
| 357 | let url = new URL(backend_addr); |
| 358 | let protocol = url.protocol || window.location.protocol; |
| 359 | url.protocol = protocol.replace('wss', 'https').replace('ws', 'http'); |
| 360 | backend_addr = url.href; |
| 361 | |
| 362 | return new Promise(function (resolve, reject) { |
| 363 | $.get(backend_addr, {test: 1}, undefined, 'html').done(function (data: string) { |
| 364 | resolve(data === 'ok'); |
| 365 | }).fail(function (e: JQuery.jqXHR) { |
| 366 | resolve(false); |
| 367 | }); |
| 368 | }); |
| 369 | } |
| 370 | |
| 371 | |
| 372 | // Send data to backend |
no test coverage detected
searching dependent graphs…