addisonelliott / httpserver Goto Github PK
View Code? Open in Web Editor NEWC++ Qt 5 HTTP Server
License: MIT License
C++ Qt 5 HTTP Server
License: MIT License
Thanks addisonElliott.
Sorry i've just read that you don't not support for qwidgets branch, i've fixed it my self.
Great repo, could you teach me that resolve is threadsafe?
Executing
HttpConnection::~HttpConnection()
{
delete timeoutTimer;
delete socket;
...
if the socket is active then the function HttpConnection::socketDisconnected() gets called, that in turn tries to call timeoutTimer->stop(), that was just destroyed.
Suggest to change the order of destruction, and for better security to disconnect all from socket:
HttpConnection::~HttpConnection()
{
disconnect(socket);
delete socket;
delete timeoutTimer;
...
Hey thanks for this server. It works great!
One of my endpoints is a hls endpoint.
It uses QFile.read(qint64 maxlen)
to read a chunk of data to send back to the front end.
When it comes time to read the chunk other threads in my application get blocked.
I am reading from a network share but I wouldn't think it would matter if its async.
I use the async method in your examples
return HttpPromise::resolve(data).then([this](HttpDataPtr data) {...});
But the threads still get blocked.
Could it be something I'm doing or an issue?
Thanks again!
Great repo. But if i want to process data (heavy task) in other thread than handler, could you teach me the way? Thanks so much.
Good piece of code. Is it possible to have a test using SSL ?
Just some comments after load test session on performances
QString str
(or other object) to const String &str
in all codemimeDatabase.mimeTypeForFile(fi, QMimeDatabase::MatchExtension).name()
take a while to be executed, so i had decided to replace it by a local cache this way:void HttpResponse::sendFile(const QString &filename, const QString &mimeType, const QString &charset, qint64 len, int compressionLevel, const QString &attachmentFilename, int cacheTime)
{
static QMap<QString, QString> mimeTypeMap;
QString finalMimeType = mimeType;
QFile file(filename);
if (!file.open(QIODevice::ReadOnly))
{
if (config_->verbosity >= HttpServerConfig::Verbose::Warning)
qWarning().noquote() << QString("Unable to open file to be sent (%1): %2").arg(filename).arg(file.errorString());
return;
}
if (mimeType.isEmpty())
{
QFileInfo fi(file);
QString suffix = fi.suffix();
if(mimeTypeMap.contains(suffix))
finalMimeType = mimeTypeMap.value(suffix);
else
{
finalMimeType = mimeDatabase.mimeTypeForFile(fi, QMimeDatabase::MatchExtension).name();
mimeTypeMap[suffix] = finalMimeType;
}
}
sendFile(&file, finalMimeType, charset, len, compressionLevel, attachmentFilename, cacheTime);
}
I have made a server which I POST a form to.
When I access a field in the form e.g.: name
I expect to do
QString name = data->request->formField("name");
However, the return type of formField(QString)
is FormFile.
HttpServer/src/httpServer/httpRequest.h
Line 134 in 3a0212c
The function formFields() does return a map of QString,QString
HttpServer/src/httpServer/httpRequest.h
Line 131 in 3a0212c
I would expect to have the value of the field returned to be a QString. Is this merely a mistake or am I missing something?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.