Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74316

Writing a deferred http response

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • Not Evaluated
    • None
    • 6.0
    • Network: HTTP
    • None

    Description

      Hi.
      I would really love to be able to handle http requests asynchronously from route handler execution.

      httpServer.route("/", [] (const QHttpServerRequest &request) {
          QTimer::singleShot(100, [httpServer, request] () {
              if(httpServer.isValid(request))
                  request.respond("Hello, world.");
          }
      
          return QHttpServer::DeferredResponse;
      });
      

      Basicaly, I'd like to store some context in the route handler, send a queued signal to object in other thread, do something there, return via queued signal back to the http server thread, and, finally, write a response.

      Do you mind telling, if there is a way to modify QHttpServer to make this possible, or do I just stick to QAbstractHttpServer?

      Thanks.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mikhailsvetkin Mikhail Svetkin
            danilshkodin danilshkodin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes