// needs a function O webServe(S uri, SS params) { ... } // and a function newWebSocket() switchable int httpPort = 80; switchable int httpsPort = 443; transient autoDispose WebSocketHTTPD httpServer; transient autoDispose WebSocketHTTPD httpsServer; switchable bool redirectHttpToHttps; transient new HTTPSpamBlocker1 spamBlocker; void start_webServers(File keyStore, S passphrase) { start_webServers(serveHttps_makeSSLSocketFactory(keyStore, passphrase)); } void start_webServers(SSLServerSocketFactory sslSocketFactory) ctex { if (httpPort != 0) { httpServer = new WebSocketHTTPD(httpPort, lambda1 newWebSocket); httpServer.enter = lambda0 enter; httpServer.serveFunction = func(S uri, SS parms) { redirectHttpToHttps && !startsWith(uri, "/.well-known/") ? serveRedirect("https://" + serveHttp_domainName() + (httpsPort == 443 ? "" : ":" + httpsPort) + uri) : webServe(uri, parms) }; httpServer.start(); print("HTTP server started on port " + httpServer.getPort()); } if (httpsPort == 0 || sslSocketFactory == null) ret; httpsServer = new WebSocketHTTPD(httpsPort, lambda1 newWebSocket); httpsServer.enter = lambda0 enter; httpsServer.makeSecure(sslSocketFactory); httpsServer.serveFunction = func(S uri, SS parms) { webServe(uri, parms) }; httpsServer.start(); print("HTTPS server started on port " + httpsServer.getPort()); }
Began life as a copy of #1027628
download show line numbers debug dex
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1029492 |
Snippet name: | HTTP+HTTPS Server Include for DynModules [WebSocket version] |
Eternal ID of this version: | #1029492/8 |
Text MD5: | 449a06dcaffd2197eebe998e12ff9a33 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-10-03 13:20:29 |
Source code size: | 1449 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 52 / 298 |
Version history: | 7 change(s) |
Referenced in: | [show references] |
Formerly at http://tinybrain.de/1029492 & http://1029492.tinybrain.de