WebSocket-Safari 9-标头值中的UTF-8序列无效 [英] WebSocket - Safari 9 - Invalid UTF-8 sequence in header value

查看:424
本文介绍了WebSocket-Safari 9-标头值中的UTF-8序列无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建可在Chrome 47.0.2526.106版(64位)中使用的WebSocket,但在Safari 9.0.2版(11601.3.9)上无法使用.错误是Invalid UTF-8 sequence in header value.似乎Safari要求包含某些标头并采用某些格式,但我找不到哪个标头.

I am creating a WebSocket that works in Chrome Version 47.0.2526.106 (64-bit) but fails on Safari Version 9.0.2 (11601.3.9). The error is Invalid UTF-8 sequence in header value. It appears that Safari is requiring certain headers to be included and in certain formats but I cannot find which.

我使用了开源WebSocketHandshake

if (valueStr.isNull()) {
    m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header value", 0, clientOrigin(), 0);
    return 0;
}

请求如下:

常规

Request URL:wss://example.server.io/query?string=test
Request Method:GET
Status Code:101 Switching Protocols

响应标题

Connection:Upgrade
Sec-WebSocket-Accept:R3JnbOI454z48aMONLd+8HP6Asg=
Set-Cookie:
Upgrade:websocket

请求标头

Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,fr;q=0.6,fr-CA;q=0.4
Cache-Control:no-cache
Connection:Upgrade
DNT:1
Host:example.server.io
Origin:http://localhost:3000
Pragma:no-cache
Sec-WebSocket-Extensions:permessage-deflate; client_max_window_bits
Sec-WebSocket-Key:QUuX6/L23NIezYa4aZJbFw==
Sec-WebSocket-Version:13
Upgrade:websocket
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36

查询字符串参数

string:test

推荐答案

Safari/WebKit不喜欢空标题.在这种情况下,问题是空的Set-Cookie:标头.这是Webkit中的错误. Chrome也有该问题,但他们在Blink中修复了该问题.
在服务器响应中删除该标头,它应该可以工作.

Safari/WebKit does not like empty headers. In this particular case, the problem is the empty Set-Cookie: header. It is a bug in Webkit. Chrome had that problem too but they fixed it in Blink.
Remove that header in the server response and it should work.

这篇关于WebSocket-Safari 9-标头值中的UTF-8序列无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆