Cutelyst 0.12.0 is out!

Cutelyst a web framework built with Qt is now closer to have it’s first stable release, with it becoming 3 years old at the end of the year I’m doing my best to finally iron it to get an API/ABI compromise, this release is full of cool stuff and a bunch of breaks which most of the time just require recompiling.

For the last 2-3 weeks I’ve been working hard to get most of it unit tested, the Core behavior is now extensively tested with more than 200 tests. This has already proven it’s benefits resulting in improved and fixed code.

Continuous integration got broader runs with gcc and clang on both OSX and Linux (Travis) and with MSVC 12 and 14 on Windows (Appveyor), luckily most of the features I wanted where implemented but the compiler is pretty upsetting. Running Cutelyst on Windows would require uwsgi which can be built with MinGW but it’s in experimental state, the developer HTTP engine, is not production ready so Windows usefulness is limited at the moment.

One of the ‘hypes’ of the moment is non-blocking web servers, and this release also fixes this so that uwsgi –async <number_of_requests> is properly handled, of course there is no magic, if you enable this on blocking code the requests will still have to wait your blocking task to finish, but there are many benefits of using this if you have non-blocking code. At the moment once a slot is called to process the request and say you want to do a GET on some webservice you can use the QNetworkAccessManager do your call and create a local QEventLoop so once the QNetworkReply finish() is emitted you continue processing. Hopefully some day QtSql module will have an async API but you can of course create a Thread Queue.

A new plugin called StatusMessage was also introduced which generates an ID which you will use when redirecting to some other page and the message is only displayed once, and doesn’t suffer from those flash race conditions.

The upload parser for Content-Type  multipart/form-data got a huge boost in performance as it now uses QByteArrayMatcher to find boundaries, the bigger the upload the more apparent is the change.

Chunked responses also got several fixes and one great improvement which will allow to use it with classes like QXmlStreamWriter by just passing the Response class (which is now a QIODevice) to it’s constructor or setDevice(), on the first write the HTTP headers are sent and it will start creating chunks, for some reason this doesn’t work when using uwsgi protocol behind Nginx, I still need to dig and maybe disable the chunks markup depending on the protocol used by uwsgi.

A Pagination class is also available to easy the work needed to write pagination, with methods to set the proper LIMIT and OFFSET on Sql queries.

Benchmarks for the TechEmpower framework were written and will be available on Round 14.

Last but not least there is now a QtCreator integration, which allows for creating a new project and Controller classes, but you need to manually copy (or link) the qtcreator directory to ~/.config/QtProject/qtcreator/templates/wizard.

cutelyst-qtwiz

As usual many bug fixes are in.

Help is welcome, you can mail me or hang on #cutelyst at freenode.

Download here.

 

Cutelyst 0.12.0 is out!

Cutelyst 0.11.0 released!

Cutelyst the Qt web framework just got a new release, I was planning to do this a while back, but you know we always want to put in a few more changes and time to do that is limited.

I was also interested in seeing if the improvements in Qt 5.6 would result in better benchmark tests but they didn’t, the hello world test app is probably too simple for the QString improvements to be noticed, a real world application using Grantlee views, Sql and more user data might show some difference. Still, compared to 0.10.0 Cutelyst is benchmarking the same even tho there were some small improvements.

The most important changes of this release were:

  • View::Email allows for sending emails using data provided on the stash, being able to chain the rendering of the email to another Cutelyst::View so for example you can have your email template in Grantlee format which gets rendered and sent via email (requires simple-mail-qt which is a fork of SmtpClient-for-Qt with a sane API, the View::Email hides simple-mail-qt API)
  • Utils::Sql provides a set of functions to be used with QSql classes, most importantly are serializing QSqlQuery to QVariantList of QVariantMap (or Hashes), allowing for accessing the query data on a View, and the preparedSqlQuery() method which comes with a macro CPreparedSqlQuery, that is a lambda that keeps your prepared statement into a static QSqlQuery, this avoids the need of QSqlQuery pointers to keep the prepared queries around (which are a boost for performance)
  • A macro CActionFor which resolves the Action into a static Action * object inside a lambda removing the need to keep resolving a name to an Action
  • Unit tests at the moment a very limited testing is done, but Header class has nearly 100% of coverage now
  • Upload parser got a fix to properly find the multipart boundary, spotted due Qt client sending boundaries a bit different from Chrome and FF, this also resulted in the removal of QRegularExpression to match the boundary part on the header with a simple search that is 5 times faster
  • Require Qt 5.5 (this allows for removal of workaround for QJson::fromHash and allows for the use of Q_ENUM and qCInfo)
  • Fixed crashes, and a memory leak is Stats where enabled
  • Improved usage of QStringLiteral and QLatin1String with clazy help
  • Added CMake support for setting the plugins install directory
  • Added more ‘const’ and ‘auto’
  • Removed uwsgi –cutelyst-reload option which never worked and can be replaced by –touch-reload and –lazy
  • Improvements and fixes on cutelyst command line tool
  • Many small bugs fixed

The Cutelyst website is powered by Cutelyst and CMlyst which is a CMS, at the moment porting CMlyst from QSettings to sqlite is on my TODO list but only when I figure out why out of the blue I get a “database locked” even if no other query is running (and yes I tried query.finish()), once I figure that out I’ll make a new CMlyst release.

Download here.

Have fun!

Cutelyst 0.11.0 released!

Cutelyst 0.10.0 released!

Cutelyst, a Qt web framework just got a new release, this version took a little longer but now I think it has evolved enough for a new version.

The more important improvements of this release were the new JSON view, which is an easy way to return a JSON response without worry with including QJson casses (all the magic is done by QJsonObject::fromVariantMap(), and the component splitting that help us get API and ABI stabilization.

The Cutelyst::Core target has all the Core functionality that simple application needs, it’s the foundation of the framework, Context, Request, Response are all core classes that one cannot live without, then you can add Cutelyst::Plugin::Session target to add Session handling functionality, which in case you don’t like it you can create your own session handling but still use Cutelyst::Core functionality. Action classes were also split out of Core, and are automatically loaded, thus only having code that you are really using ActionClass(‘REST’) will load the ActionREST plugin or fail the application if it could not be loaded.

Here is a more complete version of the changes:

  • Reduce CMake requirement to cmake 2.8.12
  • Use some Qt compile definitions to have more strict building
  • Add a JSON view which gets stash data and returns it’s data as JSON
  • Split out components, Core, View::Grantlee, View::JSON…
  • Make special Action classes loadable plugins ActionREST
  • Fix build on OSX, with a working Travis CI
  • Fix memory aliment of uWSGI plugin
  • Make Authentication methods static for convenience
  • Expose engine threads/cores information
  • Align memory of some classes
  • Fix compiling on Qt 5.5
  • Rework Session handling and extend it to match Catalyst::Plugin::Session
  • Now Controllers, Views, Plugins and DispatchTypes get automatically registered if they are children of Cutelyst::Application
  • Fix Session cookie expires
  • Require Qt 5.4 due QString::splitRef()
  • Add some more documentation
  • Removed ViewEngine class

The 0.11.0 roadmap:

  • Add unit tests, yes this is the most important thing I want to add to Cutelyst right, having API and ABI stable means nothing if internal logic changes and your app stops working the way it should on a new Cutelyst release
  • Depend on Qt 5.5
  • Declarative way of describing application (QML)
  • Some sort of Catalyst::Plugin::I18N for localization support

Have fun https://github.com/cutelyst/cutelyst/archive/r0.10.0.tar.gz!

Cutelyst 0.10.0 released!

Cutelyst 0.9.0 is out!

Cutelyst the Qt Web framework just got a new release!

I was planning to do this one after Qt 5.5 was out due to the new qCInfo() logger and Q_GADGET introspection, but I’ll save that for 0.10.0.

This release brings some important API breaks so if everything goes well I can do another CMlyst release.

  • Some small performance improvements with QStringRef usage and pre-cached _DISPATCH actions
  • Fixes when using uWSGI in threaded mode
  • Speedup uWSGI threaded mode, still slower than pre-forked but quite close
  • Fixes for the session handling as well as having static methods to make the code cleaner
  • Fix uWSGI –lazy-apps mode
  • Use PBKDF2 on Authentication plugin
  • Requite CMake 3.0 and it’s policy
  • Add Request::mangleParams() and Request::uriWith() so that Request API now covers all of Catalyst’s
  • Documented some functions

Cutelyst repository was moved to gitlab and then moved to github. The main website http://cutelyst.org is now powered by CMlyst and itself🙂

Download here.

I also started another project, html-qt is a library to create a DOM representation of HTML following the WHATWG specifications, it’s needed for CMlyst to be able to remove XSS of published posts, at the moment it has 90% of the tokenizer ready, and 5% of the parser/tree construction code, so if you have interest in the subject (could be potentially useful for mail clients such as KMail) give me a hand!

Cutelyst 0.9.0 is out!

Cutelyst 0.8.0 – featuring better stats

Cutelyst the Qt Web Framework just got a new release!

With 0.8.0 some important bugs got fixed which will allow for the CMS/Blogger app CMlyst to get a new release soon. Besides bugs being fixed a class to take out stats from the application was created, Cutelyst::Stats matches what Catalyst::Stats does, and produces a similar output:

cutelyst-stats

 

  • There you have a box, and the time which each action took to complete, looking at the /End action it is clear that it took more time but most of the time was due it calling the Grantlee View.
  • On the Request took: …  line there is the 1278.772/s value which means how many requests could be handled within a second, of course that value is for the exact same request and for the single core where it was run.
  • The first line now shows which HTTP method was used, which resource the user wants and where the request came from.

All of that can and should be disabled on production by setting cutelyst.*.debug=false on the [Rules] section of the application ini file (–ini of uWSGI). Yeah this is new too🙂

Speaking of debugging we now have more information about what user data was sent, if cutelyst.request.debug logging category is enabled you will see:

cutelyst-body A similar output is printed for url query parameters and file uploads.

The HTTP/1.1 support for chunked responses was added, once c->response()->write(…) is called the response headers are send and a chunk is sent to the client, this is new and experimental, but worked without complaints from web browsers.

An easier way to declare action arguments or capture arguments was implemented, :AutoArgs and :AutoCaptureArgs, both are not present in Perl Catalyst because there is no way to introspect methods signature in the language, @_ can provide many things, but with Qt meta information we can see which types of arguments a method has as well as how many arguments:

C_ATTR(some_method, :Local :AutoArgs)
void some_method(Context *c, const QString &year, const QString &month);

That will automatically capture two arguments matching an URL like “/some_method/2014/12”.

Last the Headers class got many fixes and improvements such as striping the fragment due RFC 2616.

As always if you have questions show up in #cutelyst at freenode or send me a mail.

Download 0.8.0 here

Enjoy!

Cutelyst 0.8.0 – featuring better stats

Cutelyst 0.7.0 is out and now has a tutorial!

Cutelyst the Qt/C++ web framework just got a new release, 0.7.0 brings many improvements, bugfixes and features.

Most notably of the changes is a shinny new Chained dispatcher that finally got implemented, with it Cutelyst Tutorial got finished, and a new command line tool to bootstrap new projects.

* Request::bodyData() can return a QJsonDocument is content-type is application/json
* Chained dispatcher
* Fixes on QStringListeral and QLatin1String usage
* More debug information
* Some API changes to match Catalyst’s
* Some rework on the API handlying Plugins (not the best thing yet)
* Moved to Gitlab (due to the gitorious being acquired by it)
* “cutelyst” command line tool

For the next release I’ll try to make the QML integration a reality, and try to improve the Plugins API, which is right now the part that needs more love would love to hear some advice.

Download it here.

Have fun!

Cutelyst 0.7.0 is out and now has a tutorial!

CMlyst got it’s first release

Now that Cutelyst is allowing me to write web applications with the tools I like, I can use it to build the kind of web applications I need but am not fine with using the existing ones…

WordPress is a great software, but it’s written in PHP, which is not a language I like, and there are many other software like this written in all sorts of languages but C++/Qt/Cutelyst, so why not?

This first release is a very shine one, it allows for templating, static pages and posts (without comments) and even a RSS feed.

To make things more interesting CMlyst has a separate library, this library abstracts the Content Management part, allowing for different backends to be written, the current one is based on QSettings files, but it’s very easy to write one for SQL, git who knows😛

I have not measured it speed against WordPress or any other CMS, it probably won’t be fair. But if you are curious I have run it against weighttp and it gives me 4k req/s on a page show, 2,5k req/s on last posts listing and 6,5k on RSS feed delivering, this on a Core2Duo 2.4Ghz, using ~10MB of RAM.

Give it a try!

Download here.

CMlyst got it’s first release