PySide6.QtHttpServer.QAbstractHttpServer¶
- class QAbstractHttpServer¶
- API to subclass to implement an HTTP server. More… - Inherited by: - QHttpServer- Synopsis¶- Methods¶- def - __init__()
- def - bind()
- def - localServers()
- def - serverPorts()
- def - servers()
 - Virtual methods¶- def - handleRequest()
- def - missingHandler()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Subclass this class and override - handleRequest()and- missingHandler()to create an HTTP server. Use- bind()to start listening to all the incoming connections to a server.- This is a low level API, see - QHttpServerfor a highler level API to implement an HTTP server.- Creates an instance of - QAbstractHttpServerwith the parent- parent.- bind(server)¶
- Parameters:
- server – - QLocalServer
- Return type:
- bool 
 
 - Bind the HTTP server to given QLocalServer - serverover which the transmission happens. It is possible to call this function multiple times with different instances of- serverto handle multiple connections.- After calling this function, every _new_ connection will be handled and forwarded by the HTTP server. - It is the user’s responsibility to call QLocalServer::listen() on the - serverbefore calling this function. If- serveris not listening, nothing will happen and- falsewill be returned.- If the - serveris nullptr false is returned.- If successful the - serverwill be parented to this HTTP server and- trueis returned.- See also - listen()- bind(server)
- Parameters:
- server – - QTcpServer
- Return type:
- bool 
 
 - Bind the HTTP server to given TCP - serverover which the transmission happens. It is possible to call this function multiple times with different instances of TCP- serverto handle multiple connections and ports, for example both SSL and non-encrypted connections.- After calling this function, every _new_ connection will be handled and forwarded by the HTTP server. - It is the user’s responsibility to call QTcpServer::listen() on the - serverbefore calling this function. If- serveris not listening, nothing will happen and- falsewill be returned.- If successful the - serverwill be parented to this HTTP server and- trueis returned.- To allow usage of HTTP 2, bind to a QSslServer where QSslConfiguration::setAllowedNextProtocols() has been called with the arguments - { QSslConfiguration::ALPNProtocolHTTP2 }.- See also - setAllowedNextProtocols()- abstract handleRequest(request, responder)¶
- Parameters:
- request – - QHttpServerRequest
- responder – - QHttpServerResponder
 
- Return type:
- bool 
 
 - Override this function to handle each incoming - request, by examining the- requestand sending the appropriate response back to- responder. Return- trueif the- requestwas handled successfully. If this method returns- false,- missingHandler()will be called afterwards.- This function must move out of - responderbefore returning- true.- http2Configuration()¶
- Return type:
 
 - Returns server’s HTTP/2 configuration parameters. - See also - localServers()¶
- Return type:
- .list of QLocalServer 
 
 - Returns the local servers of this HTTP server. - See also - abstract missingHandler(request, responder)¶
- Parameters:
- request – - QHttpServerRequest
- responder – - QHttpServerResponder
 
 
 - Override this function to handle each incoming - requestthat was not handled by- handleRequest(). This function is called whenever- handleRequest()returns- false, or if there is a WebSocket upgrade attempt and either there are no connections to- newWebSocketConnection()or there are no matching WebSocket verifiers. The- requestand- responderparameters are the same as- handleRequest()was called with.- See also - handleRequest()- addWebSocketUpgradeVerifier()- serverPorts()¶
- Return type:
- .list of quint16 
 
 - Returns the list of ports this instance of - QAbstractHttpServeris listening to.- This function has the same guarantee as QObject::children, the latest server added is the last entry in the vector. - See also - servers()¶
- Return type:
- .list of QTcpServer 
 
 - Returns the TCP servers of this HTTP server. - See also - setHttp2Configuration(configuration)¶
- Parameters:
- configuration – - QHttp2Configuration
 
 - Sets server’s HTTP/2 configuration parameters. - The next HTTP/2 connection will use the given - configuration.- See also