Compare commits

..

16 Commits
2.0.1 ... 2.0.3

Author SHA1 Message Date
6972f7a84e Merge pull request #74 from wnemay/master
Adjustments to headers during client handshake.
2016-05-10 18:02:09 +02:00
93b0b9eeaf Merge pull request #77 from thorstenfreitag/master
Compatibility for broken servers and additional authentication option instead of just basic
2016-05-10 17:52:30 +02:00
dd14850bb6 Used case insensitive recognition for upgrade header. Should work as before, but also with servers that wrongly use lower case upgrade in the header 2016-05-10 11:56:01 +10:00
d36f7bb100 Changed Header value to lower case upgrade, seems to fix connection issues with SAP HCP IoT services. Changed setAuthorization(const char * auth) to send Auth header as is, without BASIC to enable oAuth tokens in header 2016-05-09 00:11:42 +10:00
10a8d3ca67 Adding Origin, as required by spec. https://tools.ietf.org/html/rfc6455#section-1.6 2016-04-30 20:55:59 -07:00
4f55c36c80 RFC requires a port for Host when it is non default. https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23 2016-04-30 15:46:19 -07:00
b3efb316ed bump version 2016-03-16 16:25:57 +01:00
ea997cf977 update README.md 2016-03-16 16:25:31 +01:00
a103bb915c Merge remote-tracking branch 'remotes/origin/async' 2016-03-16 16:23:50 +01:00
bc58d75d71 Merge pull request #59 from uncletammy/patch-1
Added note about delay() limitation.
2016-03-16 16:23:26 +01:00
d7be7cd2fe Merge pull request #64 from urish/patch-1
fix typo: lenght -> length
2016-03-16 15:55:00 +01:00
73faf7e6b6 Merge pull request #65 from urish/patch-2
Make the `Sec-WebSocket-Protocol` header optional
2016-03-16 15:54:26 +01:00
00be8c7833 Make the Sec-WebSocket-Protocol header optional
Some server implementations (e.g. slack bots api) don't accept the connection if `Sec-WebSocket-Protocol` is specified.
2016-03-16 11:55:21 +02:00
5b4eaa0b11 fix typo: lenght -> length 2016-03-16 03:28:21 +02:00
8988faf5f0 fix #60
os_printf can not handle String direct
2016-03-05 12:13:13 +01:00
1ebae1d3e1 Add note about delay() limitation.
Change concerns issue https://github.com/Links2004/arduinoWebSockets/issues/58
2016-03-04 14:19:19 -06:00
6 changed files with 28 additions and 18 deletions

View File

@ -18,7 +18,11 @@ a WebSocket Server and Client for Arduino based on RFC6455.
- max input length is limited to the ram size and the ```WEBSOCKETS_MAX_DATA_SIZE``` define
- max output length has no limit (the hardware is the limit)
- Client send big frames with mask 0x00000000 (on AVR all frames)
##### Limitations for Async #####
- Functions called from within the context of the websocket event might not honor `yield()` and/or `delay()`. See [this issue](https://github.com/Links2004/arduinoWebSockets/issues/58#issuecomment-192376395) for more info and a potential workaround.
- wss / SSL is not possible.
##### Supported Hardware #####
- ESP8266 [Arduino for ESP8266](https://github.com/Links2004/Arduino)
- ESP31B
@ -45,8 +49,6 @@ The mode can be aktivated in the ```WebSockets.h``` (see WEBSOCKETS_NETWORK_TYPE
[ESPAsyncTCP](https://github.com/me-no-dev/ESPAsyncTCP) libary is required.
Note: in this mode wss / SSL is not possible.
### Issues ###
Submit issues to: https://github.com/Links2004/arduinoWebSockets/issues

View File

@ -22,7 +22,7 @@ WebSocketsClient webSocket;
#define USE_SERIAL Serial1
void webSocketEvent(WStype_t type, uint8_t * payload, size_t lenght) {
void webSocketEvent(WStype_t type, uint8_t * payload, size_t length) {
switch(type) {
@ -44,11 +44,11 @@ void webSocketEvent(WStype_t type, uint8_t * payload, size_t lenght) {
// webSocket.sendTXT("message here");
break;
case WStype_BIN:
USE_SERIAL.printf("[WSc] get binary lenght: %u\n", lenght);
hexdump(payload, lenght);
USE_SERIAL.printf("[WSc] get binary length: %u\n", length);
hexdump(payload, length);
// send data to server
// webSocket.sendBIN(payload, lenght);
// webSocket.sendBIN(payload, length);
break;
}

View File

@ -1,9 +1,9 @@
name=WebSockets
version=2.0
version=2.0.2
author=Markus Sattler
maintainer=Markus Sattler
sentence=WebSockets for Arduino (Server + Client)
paragraph=use 2.0 for ESP and 1.3 for AVR
paragraph=use 2.x.x for ESP and 1.3 for AVR
category=Communication
url=https://github.com/Links2004/arduinoWebSockets
architectures=*

View File

@ -181,6 +181,7 @@ typedef struct {
WSMessageHeader_t cWsHeaderDecode;
String base64Authorization; ///< Base64 encoded Auth request
String plainAuthorization; ///< Base64 encoded Auth request
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC)
String cHttpLine; ///< HTTP header lines

View File

@ -62,6 +62,7 @@ void WebSocketsClient::begin(const char *host, uint16_t port, const char * url,
_client.cExtensions = "";
_client.cVersion = 0;
_client.base64Authorization = "";
_client.plainAuthorization = "";
#ifdef ESP8266
randomSeed(RANDOM_REG32);
@ -228,7 +229,8 @@ void WebSocketsClient::setAuthorization(const char * user, const char * password
*/
void WebSocketsClient::setAuthorization(const char * auth) {
if(auth) {
_client.base64Authorization = auth;
//_client.base64Authorization = auth;
_client.plainAuthorization = auth;
}
}
@ -392,14 +394,18 @@ void WebSocketsClient::sendHeader(WSclient_t * client) {
#endif
String handshake = "GET " + client->cUrl + " HTTP/1.1\r\n"
"Host: " + _host + "\r\n"
"Upgrade: websocket\r\n"
"Host: " + _host + ":" + _port + "\r\n"
"Connection: Upgrade\r\n"
"Upgrade: websocket\r\n"
"Origin: file://\r\n"
"User-Agent: arduino-WebSocket-Client\r\n"
"Sec-WebSocket-Version: 13\r\n"
"Sec-WebSocket-Protocol: " + client->cProtocol +"\r\n"
"Sec-WebSocket-Key: " + client->cKey + "\r\n";
if(client->cProtocol.length() > 0) {
handshake += "Sec-WebSocket-Protocol: " + client->cProtocol + "\r\n";
}
if(client->cExtensions.length() > 0) {
handshake += "Sec-WebSocket-Extensions: " + client->cExtensions + "\r\n";
}
@ -408,6 +414,10 @@ void WebSocketsClient::sendHeader(WSclient_t * client) {
handshake += "Authorization: Basic " + client->base64Authorization + "\r\n";
}
if(client->plainAuthorization.length() > 0) {
handshake += "Authorization: " + client->plainAuthorization + "\r\n";
}
handshake += "\r\n";
client->tcp->write(handshake.c_str(), handshake.length());
@ -439,7 +449,7 @@ void WebSocketsClient::handleHeader(WSclient_t * client, String * headerLine) {
String headerValue = headerLine->substring(headerLine->indexOf(':') + 2);
if(headerName.equalsIgnoreCase("Connection")) {
if(headerValue.indexOf("Upgrade") >= 0) {
if(headerValue.equalsIgnoreCase("upgrade")) {
client->cIsUpgrade = true;
}
} else if(headerName.equalsIgnoreCase("Upgrade")) {
@ -617,6 +627,3 @@ void WebSocketsClient::asyncConnect() {
}
#endif

View File

@ -627,7 +627,7 @@ void WebSocketsServer::handleHeader(WSclient_t * client, String * headerLine) {
DEBUG_WEBSOCKETS("[WS-Server][%d][handleHeader] - cProtocol: %s\n", client->num, client->cProtocol.c_str());
DEBUG_WEBSOCKETS("[WS-Server][%d][handleHeader] - cExtensions: %s\n", client->num, client->cExtensions.c_str());
DEBUG_WEBSOCKETS("[WS-Server][%d][handleHeader] - cVersion: %d\n", client->num, client->cVersion);
DEBUG_WEBSOCKETS("[WS-Server][%d][handleHeader] - base64Authorization: %s\n", client->num, client->base64Authorization);
DEBUG_WEBSOCKETS("[WS-Server][%d][handleHeader] - base64Authorization: %s\n", client->num, client->base64Authorization.c_str());
bool ok = (client->cIsUpgrade && client->cIsWebsocket);