There is already a http(s) server written with/for qt in case you missed it on google…
http://www.stefanfrings.de/qtwebapp/index-en.html <http://www.stefanfrings.de/qtwebapp/index-en.html> Regards/Saygilar, Emre Beşirik nome...@gmail.com > On 07 Jan 2016, at 07:16, BRM via Interest <interest@qt-project.org> wrote: > > Thanks for the feedback. Advice and direction on this is welcome. > > I'm not sure if I'll move it towards the official Qt coding style or not - > though I'd probably accept PRs that did. I just found in trying to put > together the server for another project that there were no server-side Qt SSL > examples out there - and it was a common complaint in the various forums I > came across while searching. So I made one. I'll be the first to admit as an > example it could certainly be cleaned up more; but it's still better than > nothing (which is where we were before). There were some choices I made just > to try to keep it simple or towards being an example - I think some of them > (like the certificate verification) are commented on (or at least should be) > in the code. > > I'll certainly try to clean some things up to make it even simpler; and I'll > take a look at using the QPluginLoader with it....that's an interesting idea. > > Thanks for the advice. > > Ben > > > On Wednesday, January 6, 2016 6:54 PM, Jason H <jh...@gmx.com> wrote: > > > Don't take this the wrong way... I've written production-level HTTP SSL > servers in Qt before, and I've even requested/suggested there be a Qt C++ > server framework. So take this as advice from a veteran. > > Well, you should use QCoreApplication (drop the GUI), you never call > startSeverEncrption(), never set the validation policy of certificates, and > never actually read or write anything from the client, don't have any socket > timeouts. Other than that, it's a great server. :-) (My snarkiness is > intended to be mild-mannered). Code wise, it's not following the Qt style > guide and IMHO, makes superfluous use of namespaces. > > If this is to be for HTTP, there are many, many more challenges. The problem > is the C++ nature usually results in a a bespoke server app. However, I think > that if there were a server to use QPluginLoader, where your application was > presented as a shared library and it register itself, we'd be able to get > some traction. These days it's just easier/faster with NodeJS, and Node is > JITed. After doing that, the challenge is then constructing a framework to > handle _ALL_ the possible scenarios. LibQxt took a decent stab at it. ( > http://libqxt.bitbucket.org/doc/0.6/tech-web.html ) If you're not doing HTTP, > then you're much better off, but then you limit your clients and have to some > up with your own serialization. Things to worry about include encodings > (base64, gzip), chunked transfer encoding (content length not known at start > of transfer), and I hope multi-part mime attachments are not needed. A good > primer for low-level HTTP is https://www.jmarshall.com/easy/http/ > > I found using many QIODevice subclasses which relayed data bytes and emitted > events worked best, in that one source of bytes relays applicable bytes to > the next, Like: > QSslSocket -> HttpRequestParser -> TransferEncoding -> MIME parser -> > MimePartParser -> EncodingParser(s) -> ApplicationDataHandlers. (NodeJS calls > this 'middleware') > Your response is similarly complicated because you may be using chunked > encoding, HTTP1.1, gzip all independently of each other. > Then adding to that, it's all got to happen async if it is to be general > purpose. (That's why the emits are nice) . > > Once those are handled, I always imagined some JSON config file(s): { file: > "myapp.so", [{path: "/login", function: "some_Q_INVOKABLE(request, > response)"}, ...] } } > > It'll be much easier today than when I was doing it, as there weren't > attached properties in Qt back then (2008). > > Just my $0.02 > > Sent: Wednesday, January 06, 2016 at 4:50 PM > From: "BRM via Interest" <interest@qt-project.org> > To: "Interests Qt" <interest@qt-project.org> > Subject: [Interest] Example SSL Server based on Qt... > Over the holidays I started working on a project where I wanted to use Qt's > SSL Sockets for a client-server system. > Looking around, I didn't find an example of using them on the *server* side, > and the Qt Documentation just provides *client* side examples. > So, I pulled some parts out of my project and setup an example - you can find > it here: https://github.com/BenjamenMeyer/ExampleQtSSL > <https://github.com/BenjamenMeyer/ExampleQtSSL> > > I posted this on G+ after pushing it up; however, I figured others here might > be interested in this example as well. > > Presently the example is a simple 3 part project consisting of (i) client, > (ii) server, and (iii) common static library between the two. > The client and server both operate as GUI programs with a simple text display > to show what is going on, as well as a basic file log for more extensive > diagnostics. > > PR's welcome if anyone wants to help make it even better. I'll probably make > a daemonized version of the service at some point. > > Ben > _______________________________________________ Interest mailing list > Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest > <http://lists.qt-project.org/mailman/listinfo/interest> > > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest