fix for some FireFox cases
Chrome send "Connection: Upgrade" while FF has "Connection: keep-alive, Upgrade"
This commit is contained in:
parent
365fc08719
commit
5d49d9280e
|
@ -574,13 +574,10 @@ abyss_bool websocket_hook(TSession *r)
|
||||||
switch_event_node_t *nodes[MAX_EVENT_BIND_SLOTS];
|
switch_event_node_t *nodes[MAX_EVENT_BIND_SLOTS];
|
||||||
int node_count = 0;
|
int node_count = 0;
|
||||||
char *p;
|
char *p;
|
||||||
char *key = TableFind(&r->requestHeaderFields, "sec-websocket-key");
|
char *key = NULL;
|
||||||
char *version = TableFind(&r->requestHeaderFields, "sec-websocket-version");
|
char *version = NULL;
|
||||||
char *proto = TableFind(&r->requestHeaderFields, "sec-websocket-protocol");
|
char *proto = NULL;
|
||||||
char *upgrade = TableFind(&r->requestHeaderFields, "connection");
|
char *upgrade = NULL;
|
||||||
|
|
||||||
if (!key || !version || !proto || !upgrade) return FALSE;
|
|
||||||
if (strncasecmp(upgrade, "Upgrade", 7) || strncasecmp(proto, "websocket", 9)) return FALSE;
|
|
||||||
|
|
||||||
for (i = 0; i < r->requestHeaderFields.size; ++i) {
|
for (i = 0; i < r->requestHeaderFields.size; ++i) {
|
||||||
TTableItem * const fieldP = &r->requestHeaderFields.item[i];
|
TTableItem * const fieldP = &r->requestHeaderFields.item[i];
|
||||||
|
@ -589,6 +586,14 @@ abyss_bool websocket_hook(TSession *r)
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "headers %s: %s\n", fieldP->name, fieldValue);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "headers %s: %s\n", fieldP->name, fieldValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
key = TableFind(&r->requestHeaderFields, "sec-websocket-key");
|
||||||
|
version = TableFind(&r->requestHeaderFields, "sec-websocket-version");
|
||||||
|
proto = TableFind(&r->requestHeaderFields, "sec-websocket-protocol");
|
||||||
|
upgrade = TableFind(&r->requestHeaderFields, "connection");
|
||||||
|
|
||||||
|
if (!key || !version || !proto || !upgrade) return FALSE;
|
||||||
|
if (!strstr(upgrade, "Upgrade") || strncasecmp(proto, "websocket", 9)) return FALSE;
|
||||||
|
|
||||||
ret = ws_init(&wsh, r, NULL, 0);
|
ret = ws_init(&wsh, r, NULL, 0);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "websocket error %d\n", ret);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "websocket error %d\n", ret);
|
||||||
|
|
Loading…
Reference in New Issue