QWebSocketServer doesn't work with Chrome in norway on saturdays and sundays
When a chrome browser is setting up a websocket connection with a QWebSocketServer, it fails with the error-message :
WebSocket connection to 'ws://localhost:9090/' failed: Invalid UTF-8 sequence in header value.
Works fine on recent versions of Opera, Firefox and IE
What is strange is it worked yesterday (friday 15.08.2014). Today, saturday (16.08.2014) it doesn't work.
Now, I've been investigating this, and I think I have found a possible reason. I think it has something to do with how the class
QWebSocketHandshakeResponse is building it's headers. Here is how the result looks like TODAY :
HTTP/1.1 101 Switching Protocols
Date: lø, 16 aug 2014 12:29:41 GMT
Look at the last header, Date. It contains a non-UTF-8 letter : 'ø', because saturday in norwegian is LØRDAG. Now look at how the response is being built :
response << QStringLiteral("Server: ") % serverName <<
QStringLiteral("Access-Control-Allow-Credentials: false") <<
QStringLiteral("Access-Control-Allow-Methods: GET") <<
QStringLiteral("Access-Control-Allow-Headers: content-type") <<
QStringLiteral("Access-Control-Allow-Origin: ") % origin <<
QStringLiteral("Date: ") %
.toString(QStringLiteral("ddd, dd MMM yyyy hh:mm:ss 'GMT'"));
So the Date header is built using the QDateTime class. Looking at the toString function :
QString QDateTime::toString(const QString& format) const
return QLocale::system().toString(*this, format);
it seems to me that it is not possible the change the language, for instance like this :
QLocale loc(QLocale::English, QLocale::Norway);
because it's going to use the system locale anyway. Because of this, i think that QWebSocket connections is not going to work with Chrome on saturdays (LØRDAG; lø) or sundays (SØNDAG; sø).
Is this a bug, or am I just doing it wrong? Suggestions of how to fix it?
[edit: added missing coding tags @ SGaist]
Hi and welcome to devnet,
Looks like you may have found something. You should go to the "bug report system":http://bugreports.qt-project.org and see it's something known. If not please consider opening a new report providing all the infos you have found, it will be very helpful.
Thanks, I opened a new report
Can you also share the link to the report ? So other people finding this thread may get to it directly