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

QHttpAbstractServer does not follow server listen() convention

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 6.0 (Next Major Release)
    • Fix Version/s: None
    • Component/s: Network: HTTP
    • Labels:
      None
    • Commits:
      93ff67a3fce7ebe477085541217eef4000e310be (qt-labs/qthttpserver/master)

      Description

      I don't think QAbstractHttpServer::listen() returning the port or -1 on failure is a good idea. QTcpServer sets precedent and QWebSockerServer, QSctpServer follow, where listen() is a bool:
      bool QTcpServer::listen(const QHostAddress &address = QHostAddress::Any, quint16 port = 0);
      quint16 QTcpServer::serverPort() const;

      I'd expect the convention to be followed? It's going to mess me up if I have to check for -1 return on some listens() and not others. For example:

      if (server.listen(8080)) {
      // I expect to be listening
      }
      

      Will execute as expected for all but the HTTP servers, but will still execute as success when QAbstractHttpServer returns -1 when it actually failed.

        Attachments

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

          Activity

            People

            Assignee:
            mikhailsvetkin Mikhail Svetkin
            Reporter:
            jasonapk Jason Hihn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes