mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-07-15 00:06:30 +02:00
Fix empty header issue
This commit is contained in:
@ -137,7 +137,7 @@ void setup() {
|
|||||||
|
|
||||||
// connect to websocket
|
// connect to websocket
|
||||||
webSocket.begin(ws_host, ws_port, socketUrl);
|
webSocket.begin(ws_host, ws_port, socketUrl);
|
||||||
webSocket.setExtraHeaders(""); // remove "Origin: file://" header because it breaks the connection with Spring's default websocket config
|
webSocket.setExtraHeaders(); // remove "Origin: file://" header because it breaks the connection with Spring's default websocket config
|
||||||
// webSocket.setExtraHeaders("foo: I am so funny\r\nbar: not"); // some headers, in case you feel funny
|
// webSocket.setExtraHeaders("foo: I am so funny\r\nbar: not"); // some headers, in case you feel funny
|
||||||
webSocket.onEvent(webSocketEvent);
|
webSocket.onEvent(webSocketEvent);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
WebSocketsClient::WebSocketsClient() {
|
WebSocketsClient::WebSocketsClient() {
|
||||||
_cbEvent = NULL;
|
_cbEvent = NULL;
|
||||||
_client.num = 0;
|
_client.num = 0;
|
||||||
_client.extraHeaders = "Origin: file://";
|
_client.extraHeaders = WEBSOCKETS_STRING("Origin: file://");
|
||||||
}
|
}
|
||||||
|
|
||||||
WebSocketsClient::~WebSocketsClient() {
|
WebSocketsClient::~WebSocketsClient() {
|
||||||
@ -490,7 +490,9 @@ void WebSocketsClient::sendHeader(WSclient_t * client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add extra headers; by default this includes "Origin: file://"
|
// add extra headers; by default this includes "Origin: file://"
|
||||||
handshake += client->extraHeaders + NEW_LINE;
|
if (client->extraHeaders) {
|
||||||
|
handshake += client->extraHeaders + NEW_LINE;
|
||||||
|
}
|
||||||
|
|
||||||
handshake += WEBSOCKETS_STRING("User-Agent: arduino-WebSocket-Client\r\n");
|
handshake += WEBSOCKETS_STRING("User-Agent: arduino-WebSocket-Client\r\n");
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ class WebSocketsClient: private WebSockets {
|
|||||||
void setAuthorization(const char * user, const char * password);
|
void setAuthorization(const char * user, const char * password);
|
||||||
void setAuthorization(const char * auth);
|
void setAuthorization(const char * auth);
|
||||||
|
|
||||||
|
void setExtraHeaders(const char * extraHeaders = NULL);
|
||||||
void setExtraHeaders(char * extraHeaders);
|
void setExtraHeaders(char * extraHeaders);
|
||||||
void setExtraHeaders(const char * extraHeaders);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
String _host;
|
String _host;
|
||||||
|
Reference in New Issue
Block a user