Skip to content

Commit 187a4ac

Browse files
committed
bump version
optimize String usage (less malloc / realloc) remove double debug line
1 parent d2d06b5 commit 187a4ac

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=WebSockets
2-
version=1.0
2+
version=1.1
33
author=Markus Sattler
44
maintainer=Markus Sattler
55
sentence=WebSockets for Arduino (Server + Client)

src/WebSocketsClient.cpp

+13-16
Original file line numberDiff line numberDiff line change
@@ -272,25 +272,22 @@ void WebSocketsClient::sendHeader(WSclient_t * client) {
272272

273273
unsigned long start = micros();
274274

275-
String handshake;
276-
handshake="GET "+client->cUrl+" HTTP/1.1\r\n";
277-
handshake+="Host: "+_host+"\r\n";
278-
handshake+="Upgrade: websocket\r\n";
279-
handshake+="Connection: Upgrade\r\n";
280-
handshake+="User-Agent: arduino-WebSocket-Client\r\n";
281-
handshake+="Sec-WebSocket-Version: 13\r\n";
282-
handshake+="Sec-WebSocket-Protocol: arduino\r\n";
283-
handshake+="Sec-WebSocket-Key: "+client->cKey+"\r\n";
284-
285-
if(client->cExtensions.length() > 0) {
286-
handshake+="Sec-WebSocket-Extensions: "+client->cExtensions+"\r\n";
275+
String handshake = "GET " + client->cUrl + " HTTP/1.1\r\n"
276+
"Host: " + _host + "\r\n"
277+
"Upgrade: websocket\r\n"
278+
"Connection: Upgrade\r\n"
279+
"User-Agent: arduino-WebSocket-Client\r\n"
280+
"Sec-WebSocket-Version: 13\r\n"
281+
"Sec-WebSocket-Protocol: arduino\r\n"
282+
"Sec-WebSocket-Key: " + client->cKey + "\r\n";
283+
284+
if(client->cExtensions.length() > 0) {
285+
handshake += "Sec-WebSocket-Extensions: " + client->cExtensions + "\r\n";
287286
}
288-
289-
handshake+="\r\n";
290-
client->tcp.write(handshake.c_str(), handshake.length());
291287

292-
DEBUG_WEBSOCKETS("[WS-Client][sendHeader] sending header... Done (%uus).\n", (micros() - start));
288+
handshake += "\r\n";
293289

290+
client->tcp.write(handshake.c_str(), handshake.length());
294291

295292
DEBUG_WEBSOCKETS("[WS-Client][sendHeader] sending header... Done (%uus).\n", (micros() - start));
296293

0 commit comments

Comments
 (0)