Coder Social home page Coder Social logo

httpserver's People

Contributors

addisonelliott avatar azertyalex avatar marcolaz avatar navrocky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

httpserver's Issues

Possible crash in HttpConnection::~HttpConnection()

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;
    ...

Async endpoint blocking threads

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!

processing in other thread

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.

perf comments

Just some comments after load test session on performances

  1. My tests have only been be performed on macOS 10.15.4 with Instruments Time profile Apple tool, I have planned to do on Win 10 and Arch Linux soon
  2. Passing String by value instead of by reference have a perf impact as expected, i had decided to transform all QString str (or other object) to const String &str in all code
  3. senFile() is most used function (for my usage) and macOS implementation of mimeDatabase.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);
}

Weird return when requesting formField

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.

FormFile formField(QString key) const;

The function formFields() does return a map of QString,QString

std::unordered_map<QString, QString> formFields() const;

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.