Qhttp Post method Sample Require !
Page |
1 |
Hello All
i am new to Qt I have to sent Requet to Web Serve through Qhttp Post method
so any one can share the working sample of Qhttp Post
i want to use for Symbain
Thanks in Advance
24 replies
Hi,
just call the post method of QNetworkAccessManager, i.e.
passing:
- a QNetworkRequest built the URL that you wish to contact, without the query part.
- a QByteArray filled with your request parameters, i.e. “param1=value1¶m2=value2& … “
It works for Desktop, but it should work for Symbian too.
Of course you’ll get a QNetworkReply, but you’ll manage it in the same way as GET method, so you can read some other examples related to QNetworkReply.
Tony.
This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.
You should go with“QNetworkAccessManager”:http://doc.qt.nokia.com/4.7/qnetworkaccessmanager.html and it’s post() [doc.qt.nokia.com] method together with QNetworkRequest [doc.qt.nokia.com]
You’re right, it is more flexible, what I meant by practical is just that, what makes the Qt Framework so cool is not just the functionality, but the fact that the framework feels “natural”.
So the fact that they removed QHttp which made HTTP network access more “natural” or easier to use, they whould have just improved QHttp and keep it easy to use, instead of implementing something new like QNetworkAccessManager and making it harder to use.
I just hope that they don’t make a lot of changes like that, which makes Qt less understandable, and keep it like it is right now, “natural”.
Yeah, I can still use it, but being deprecated it’s not really a good practice to continue using it.
I’ll learn about QNetworkAccessManager and hope that things don’t get too complicated for simple tasks ;)
And in the future there are changes in the API that I think could be done better, that’s the great thing about open source and having wikis and forums, people can contribute, give opinions and improvements.
A SOAP and REST producer/consumer, for producer I need to build an HTTP Server, and for a client I need to be able to post information to the server.
It’s pretty much a lot of XML/text parsing, and using the HTTP or HTTPS protocol as a transport, for me I felt it was cleaner to use QHttp, because if I want to exchange transports, it sounds more practical to just change QHttp to QFtp to QSomeOtherProtocol, than having to exchange QNetworkAccessManager with QFtp.
As I wrote earlier, it’s for better readability and to make the code more “natural”.
Hello All
i am new to Qt I have to sent Requet to Web Serve through Qhttp Post method
so any one can share the working sample of Qhttp Posti want to use for Symbain
Thanks in Advance
This [wiki.forum.nokia.com] wiki article may help you.
…for me I felt it was cleaner to use QHttp, because if I want to exchange transports, it sounds more practical to just change QHttp to QFtp to QSomeOtherProtocol, than having to exchange QNetworkAccessManager with QFtp. As I wrote earlier, it’s for better readability and to make the code more “natural”.
QNetworkAccessManager does support FTP too; you would only have to change the URLs of your request and not even exchange some classes.
Ok cool, and is it easy to implement my own protocols? by just implementing my own protocol class would the QNetworkAccessManager know what class to call depending on what you place on the URL?
Simply subclass QNetworkAccessManager, override its createRequest1 method, and in there check the protocol inside the URL: if it’s your custom protocol, do whatever you have to do to serve the request and return a custom QNetworkReply subclass. Otherwise simply call the base class implementation.
Remember that QNAM / QNR design is 100% asynchronous, therefore you’re not expected to block in any case.
1 Quite a strange name, since it actually creates a reply!
You must log in to post a reply. Not a member yet? Register here!




