Details
-
Bug
-
Resolution: Cannot Reproduce
-
P2: Important
-
4.7.0
-
None
-
Tested under Linux, but seems to be platform independent
Description
When creating a QNetworkRequest from a QUrl that contains a userInfo, it automatically triggers an HTTP Basic Auth. As long as the user name contains no whitespaces, everything works fine:
QNetworkRequest req(QUrl("http://TestUser:testpw@localhost/")); ... start the request ... (Server receives user name "TestUser" and password "testpw")
However, when the QUrl::userName() contains a whitespace, an empty password is transmitted to the server:
QNetworkRequest req(QUrl("http://Test%20User:testpw@localhost/")); ... start the request ... (Server receives user name "TestUser" and password "")
I'm currently using the following workaround, providing the "Authorization" header by hand:
QNetworkRequest req(QUrl("http://localhost/")); req.setRawHeader("Authorization", "Basic " + QByteArray("Test User:testpw").toBase64()); ... start the request ... (Server receives user name "TestUser" and password "testpw")
But I don't think this is the intended way of providing authorization.