Browse Source

Updated libjuice to v1.5.1

Paul-Louis Ageneau 1 year ago
parent
commit
d624c8245b
2 changed files with 14 additions and 10 deletions
  1. 1 1
      deps/libjuice
  2. 13 9
      src/impl/wshandshake.cpp

+ 1 - 1
deps/libjuice

@@ -1 +1 @@
-Subproject commit 2bb0eedfe721def2543c023fd179815acea5dfb0
+Subproject commit 813c0018d2492fdb4ef21ae61aff7914314b1aaf

+ 13 - 9
src/impl/wshandshake.cpp

@@ -64,7 +64,7 @@ string WsHandshake::generateHttpRequest() {
 	             "Host: " +
 	             mHost +
 	             "\r\n"
-	             "Connection: upgrade\r\n"
+	             "Connection: Upgrade\r\n"
 	             "Upgrade: websocket\r\n"
 	             "Sec-WebSocket-Version: 13\r\n"
 	             "Sec-WebSocket-Key: " +
@@ -80,12 +80,18 @@ string WsHandshake::generateHttpRequest() {
 
 string WsHandshake::generateHttpResponse() {
 	std::unique_lock lock(mMutex);
-	const string out = "HTTP/1.1 101 Switching Protocols\r\n"
-	                   "Server: libdatachannel\r\n"
-	                   "Connection: upgrade\r\n"
-	                   "Upgrade: websocket\r\n"
-	                   "Sec-WebSocket-Accept: " +
-	                   computeAcceptKey(mKey) + "\r\n\r\n";
+
+	string out = "HTTP/1.1 101 Switching Protocols\r\n"
+	             "Server: libdatachannel\r\n"
+	             "Connection: Upgrade\r\n"
+	             "Upgrade: websocket\r\n"
+	             "Sec-WebSocket-Accept: " +
+	             computeAcceptKey(mKey) + "\r\n";
+
+	if (!mProtocols.empty())
+		out += "Sec-WebSocket-Protocol: " + utils::implode(mProtocols, ',') + "\r\n";
+
+	out += "\r\n";
 
 	return out;
 }
@@ -119,8 +125,6 @@ string WsHandshake::generateHttpError(int responseCode) {
 	const string out = "HTTP/1.1 " + error +
 	                   "\r\n"
 	                   "Server: libdatachannel\r\n"
-	                   "Connection: upgrade\r\n"
-	                   "Upgrade: websocket\r\n"
 	                   "Content-Type: text/plain\r\n"
 	                   "Content-Length: " +
 	                   to_string(error.size()) +