Why QHttpRequestHeader / QHttpResponseHeader are deprecated?
-
I just moved to new Qt and discovered that QHttpRequestHeader / QHttpResponseHeader classes are obsolete.
What is a reason and what should I use instead in order to implement http requests? I am aware about QNetworkAccessManager class and it is very convenient for client implementation but it is pretty unusable for server implementation.
-
Yes, you are right, QTcpSocket is a right way to implement server on low level.
But then http server should accept http header, parse it, analyse it and send http response. QHttpRequestHeader / QHttpResponseHeader classes are very convenient for that and they save some manual parsing.
So, probably the right question is: "why QHttp class is obsolete"?
-
QNetworkAccessManager is much more flexible and not limited to a single protocol. With QHttp/QFtp you had to decide on the application level which protocol to use, with QNAM you leave that to the network layer and only pass an URL to it.
You can still use QHttpRequestHeader and QHttpResponseHeader for your purposes. As Qt 4 will be source compatible for its lifetime you must not worry that it vanishes sometime in the future. That could only happen with a Qt 5.