[Qtwebengine] QWebEngineUrlRequestInterceptor does not set HTTP headers for request resulted from redirect

Alon Bar-Lev alon.barlev at gmail.com
Wed Dec 13 13:06:15 CET 2023


Hello,

I am trying to use the QWebEngine to perform SSO based on the
Microsoft ProofOfPossession protocol in which I need to set headers
requests including redirects.

It seems like the QWebEngineUrlRequestInterceptor works and sets the
headers for most request, however, it is ignoring the set headers when the
request is a redirect request. Aka a site returns 302 and as result a GET
request should be invoked with additional headers.

I could not find how I can inject headers in any other way to requests.

I am using PyQt6_WebEngine-6.6.0 think it is not related to python wrapper
I also tested PyQtWebEngine-5.15.6 it behaves the same.

Any clue? Any other ideas? How can I set headers of all requests?

Thanks,
Alon

---

class WebEngineUrlRequestInterceptor(QWebEngineUrlRequestInterceptor):
    def interceptRequest(self, info):
            info.setHttpHeader("test1".encode("ascii"),
"value1".encode("ascii"))

class Example(QMainWindow):
    def __init__(self):
        super(Example, self).__init__()

        self.profile = QWebEngineProfile()
        self.interceptor = WebEngineUrlRequestInterceptor()
        self.profile.setUrlRequestInterceptor(self.interceptor)
        self.page = QWebEnginePage(self.profile)
        self.webEngineView = QWebEngineView(self.page, self)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qtwebengine/attachments/20231213/84deccaa/attachment.htm>


More information about the QtWebEngine mailing list