[Qtwebengine] QWebEngineUrlRequestInterceptor does not set HTTP headers for request resulted from redirect
Allan Jensen
Allan.Jensen at qt.io
Wed Dec 13 14:48:14 CET 2023
Sounds like you are looking for a way to add request headers. Not sure there
is header in a redirect response, that would trigger the client to use the
header to the redirected request.
We had patches for 6.6 to add request headers to the API, but it wasn't
working consistently. If you could open a bug with you needs to we perhaps
improve on the old patch and create something suited for your needs.
best regards,
Allan
On Mittwoch, 13. Dezember 2023 13:06:15 CET Alon Bar-Lev wrote:
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)
More information about the QtWebEngine
mailing list