QWebSocketCorsAuthenticator 類為 CORS (跨來源請求) 提供身份驗證器對象。 更多...
| 頭: | #include <QWebSocketCorsAuthenticator> |
| qmake: | QT += websockets |
| Since: | Qt 5.3 |
該類在 Qt 5.3 引入。
| QWebSocketCorsAuthenticator (QWebSocketCorsAuthenticator && other ) | |
| QWebSocketCorsAuthenticator (const QWebSocketCorsAuthenticator & other ) | |
| QWebSocketCorsAuthenticator (const QString & origin ) | |
| QWebSocketCorsAuthenticator & | operator= (const QWebSocketCorsAuthenticator & other ) |
| QWebSocketCorsAuthenticator & | operator= (QWebSocketCorsAuthenticator && other ) |
| ~QWebSocketCorsAuthenticator () | |
| bool | allowed () const |
| QString | origin () const |
| void | setAllowed (bool allowed ) |
| void | swap (QWebSocketCorsAuthenticator & other ) |
QWebSocketCorsAuthenticator 類被用於 originAuthenticationRequired() 信號。類提供辦法把要求信息傳遞迴 QWebSocketServer 。它為應用程序提供哪些來源 URL 被允許,哪些不被允許的細粒度控製。默認情況下,接受每個來源。為獲得細粒度控製,應用程序連接 originAuthenticationRequired() 信號到槽。當來源 ( QWebSocketCorsAuthenticator::origin ()) 被接受,它調用 QWebSocketCorsAuthenticator::setAllowed (true)
注意: 當憑藉非瀏覽器客戶端訪問服務器時,校驗來源沒有多大意義,因為這種客戶端可以設置它喜歡的任何來源的 Header (頭)。若是瀏覽器客戶端,服務器應該校驗來源的有效性。
另請參閱 WebSocket Security Considerations and QWebSocketServer .
移動構造 QWebSocketCorsAuthenticator,使之指嚮同一對象 other 所指嚮的。
構造副本為 other .
構造新 QCorsAuthencator 對象采用給定 origin .
注意: 默認情況下, allowed () 返迴 true。這意味著默認接受每個來源。
賦值 other 到此身份驗證器對象。
移動賦值 other 到此實例。
銷毀對象。
返迴 true 若來源是允許的,否則返迴 false。
注意: 默認情況下,所有來源均被接受。
另請參閱 setAllowed ().
返迴此身份驗證器正在處理的有關來源。
允許或禁止來源。設置 allowed 為 true,將接受給定來源的連接請求。
設置 allowed 為 false,將拒絕連接請求。
注意: 默認情況下,所有來源均被接受。
另請參閱 allowed ().
交換 other 與此身份驗證器。
此操作很快且從不失敗。