File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -226,6 +226,8 @@ typedef struct {
226
226
String base64Authorization; // /< Base64 encoded Auth request
227
227
String plainAuthorization; // /< Base64 encoded Auth request
228
228
229
+ String extraHeaders;
230
+
229
231
bool cHttpHeadersValid; // /< non-websocket http header validity indicator
230
232
size_t cMandatoryHeadersCount; // /< non-websocket mandatory http headers present count
231
233
Original file line number Diff line number Diff line change 29
29
WebSocketsClient::WebSocketsClient () {
30
30
_cbEvent = NULL ;
31
31
_client.num = 0 ;
32
+ _client.extraHeaders = " Origin: file://" ;
32
33
}
33
34
34
35
WebSocketsClient::~WebSocketsClient () {
@@ -274,6 +275,15 @@ void WebSocketsClient::setAuthorization(const char * auth) {
274
275
}
275
276
}
276
277
278
+ /* *
279
+ * set extra headers for the http request;
280
+ * separate headers by "\r\n"
281
+ * @param extraHeaders const char * extraHeaders
282
+ */
283
+ void WebSocketsClient::setExtraHeaders (const char * extraHeaders) {
284
+ _client.extraHeaders = extraHeaders;
285
+ }
286
+
277
287
// #################################################################################
278
288
// #################################################################################
279
289
// #################################################################################
@@ -479,10 +489,8 @@ void WebSocketsClient::sendHeader(WSclient_t * client) {
479
489
handshake += WEBSOCKETS_STRING (" Connection: keep-alive\r\n " );
480
490
}
481
491
482
- #ifndef WEBSOCKET_HEADERS_NO_ORIGIN
483
- // add origin header if requested
484
- handshake += WEBSOCKETS_STRING (" Origin: file://\r\n " );
485
- #endif
492
+ // add extra headers; by default this includes "Origin: file://"
493
+ handshake += client->extraHeaders + NEW_LINE;
486
494
487
495
handshake += WEBSOCKETS_STRING (" User-Agent: arduino-WebSocket-Client\r\n " );
488
496
Original file line number Diff line number Diff line change @@ -80,6 +80,9 @@ class WebSocketsClient: private WebSockets {
80
80
81
81
void setAuthorization (const char * user, const char * password);
82
82
void setAuthorization (const char * auth);
83
+
84
+ void setExtraHeaders (char * extraHeaders);
85
+ void setExtraHeaders (const char * extraHeaders);
83
86
84
87
protected:
85
88
String _host;
You can’t perform that action at this time.
0 commit comments