Skip to content

HTTP server library in C++, based on Qt Framework. This fork adds a new method for faster response sending.

License

Notifications You must be signed in to change notification settings

fluxlinkage/QtWebApp-faster

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This fork adds a HttpResponse::writeSingle method, which can write both HTTP header and body to the socket with a single HttpResponse::writeToSocket call. It could be much faster than HttpResponse::write method under certain conditions, especially when your network is very fast or your client and server are running on a same machine ( in that case, using HttpResponse::write may cause HTTP header and body sent in multiple packets ).

SpeedTestServer and SpeedTestClient demonstrate how to use HttpResponse::writeSingle.

Example test results ( SpeedTestServer and SpeedTestClient running on a same Debian 10 machine with Qt 5.12.12 ):

Avg. time cost for /common = 46.760771 ms
Avg. time cost for /fast = 0.200236 ms

[2024.04.24 Update]

Adds ECC key support. Add the following setting to the configuration file:

sslCertMethod=EC

Setting sslCertMethod to RSA or not setting sslCertMethod to use RSA key.

Setting sslCertMethod to DSA may also work (Not tested).

The following are the orignial readme.


QtWebApp HTTP Server in C++

Fork from Stefan's QtWebApp: http://stefanfrings.de/qtwebapp/index-en.html

QtWepApp is a HTTP server library in C++, inspired by Java Servlets. For Linux, Windows, Mac OS and many other operating systems that the Qt Framework supports.

QtWebApp contains the following components:

  • HTTP(S) Server
  • Template Engine
  • File Logger
  • These components can be used independently of each other.
  • The logger improves disk space and performance by retaining debug messages in memory until an error occurs. No debug messages are written as long everything works fine. Changes to the configuration of the logger become active automatically without program restart. A very small example:

Usage

This short example demonstrates how to use the library:

// The request handler receives and responds HTTP requests
void MyRequestHandler::service(HttpRequest& request, HttpResponse& response)
{
    // Get a request parameters
    QByteArray username = request.getParameter("username");

    // Set a response header
    response.setHeader("Content-Type", "text/html; charset=UTF-8");

    // Generate the HTML document
    response.write("<html><body>");
    response.write("Hello ");
    response.write(username);
    response.write("</body></html>");
}

// The main program starts the HTTP server
int main(int argc, char *argv[])
{
    QCoreApplication app(argc,argv);

    new HttpListener(
        new QSettings("configfile.ini",QSettings::IniFormat,&app),
        new MyRequestHandler(&app),
        &app);

    return app.exec();
}

Tutorial

API documentation

See also

About

HTTP server library in C++, based on Qt Framework. This fork adds a new method for faster response sending.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 84.6%
  • Prolog 11.6%
  • QMake 2.7%
  • Other 1.1%