Skip to content

Commit

Permalink
Merge pull request #2321 from WebFreak001/fix-websockets
Browse files Browse the repository at this point in the history
Fix wss/ws websocket connection fix #2320
merged-on-behalf-of: Sönke Ludwig <s-ludwig@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Jun 15, 2019
2 parents 09e7565 + a966f56 commit 0b434ca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion http/vibe/http/websockets.d
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class WebSocketException: Exception
*/
WebSocket connectWebSocket(URL url, const(HTTPClientSettings) settings = defaultSettings)
@safe {
const use_tls = (url.schema == "wss" || url.schema == "https") ? true : false;
url.schema = use_tls ? "https" : "http";

auto rng = secureRNG();
auto challengeKey = generateChallengeKey(rng);
auto answerKey = computeAcceptKey(challengeKey);
Expand All @@ -108,7 +111,7 @@ WebSocket connectWebSocket(URL url, const(HTTPClientSettings) settings = default
/// ditto
void connectWebSocket(URL url, scope WebSocketHandshakeDelegate del, const(HTTPClientSettings) settings = defaultSettings)
@safe {
bool use_tls = (url.schema == "wss") ? true : false;
const use_tls = (url.schema == "wss" || url.schema == "https") ? true : false;
url.schema = use_tls ? "https" : "http";

/*scope*/auto rng = secureRNG();
Expand Down
2 changes: 1 addition & 1 deletion tests/vibe.http.websocket.2169/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void test(bool tls)
}));

const serverAddr = listener.bindAddresses[0];
const server_url = URL((tls ? "https://" : "http://") ~ serverAddr.toString);
const server_url = URL((tls ? "wss://" : "ws://") ~ serverAddr.toString);

runTask({
scope(exit) exitEventLoop(true);
Expand Down

0 comments on commit 0b434ca

Please sign in to comment.