Webkit under Windows with PyQt doesn't get remote resources via xhr
Question: I would like to write a Qt application which uses Webkit as its gui to get
data from a server and display it. I got it working unter Linux and OS X
without problems but under windows the XMLHttpRequest always returns status 0
and I don't know why. Here is the pyqt code I use:

    
    
    import sys, os
    from PyQt4.QtCore import *
    from PyQt4.QtGui import *
    from PyQt4.QtWebKit import *
    
    app = QApplication(sys.argv)
    web = QWebView()
    web.page().settings().setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True)
    path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'index.html'))
    url = "file://localhost/" + path
    web.load(QUrl(url))
    web.show()
    sys.exit(app.exec_())
    

and here is html HTML/JS I use to test it:

    
    
    <!DOCTYPE html>
    <title>TEST</title>
    <h1>TEST</h1>
    <div id="test"></div>
    <script type="text/javascript">
        function t(text) { document.getElementById("test").innerHTML = text }
    
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
            if(this.status != 0)
                t(this.responseText)
            else
                t("Status is 0")
        }
        xhr.open("GET", "https://jeena.net/")
        xhr.send()
    </script>
    

On Linux it opens a new Window with a WebKit view in it, loads html local
index.html file into it and renders it which shows the TEST headline. After
that it runs the XMLHttpRequest code to get a websites content and set it with
innerHTML into the prepared div.

On windows it loads and shows the title but then when it runs the xhr code the
status is always just 0 and it never changes, no matter what I do.

As far as I understand `LocalContentCanAccessRemoteUrls` should make it
possible for the xhr to get that content from the remote website even on
windows, any idea why this is not working? I am using Qt version 4.9.6 on my
windows machine and python v2.7.


Answer: I think there are two simple attempts to solve this problem.

My first thinking is that it can be due to cross domain request. Seems that
there is no easy way to disable cross domain protection in QWebkit. I got the
information from this stackoverflow question:

[QtWebkit Same-Origin-
policy](http://stackoverflow.com/questions/8090462/qtwebkit-same-origin-
policy)

As stated in the accepted answer:

"By default, Qt doesn't expose method to disable / whitelist the same origin
policy. Extended the same (qwebsecurityorigin.cpp) and able to get it
working."

But since you've got everything working on linux and mac, the above may not be
the cause.

Another possibility is you don't have openssl enabled with your Qt on windows.
Since I noticed you have requested to a **https** page, which should require
openssl. You can change the page to a **http** one to quick test this
possibility.

