XMLHttpRequest onreadystatechange never called when doing a post to certain https urls
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ubuntu-ui-toolkit (Ubuntu) |
Confirmed
|
Medium
|
Unassigned |
Bug Description
While attempting to write an application that required authenticating with a REST API, I discovered that when posting to the end point, onreadystatechange for the request object was never called. However, the same code worked fine in a web browser.
I boiled down the code to the smallest sample that I could. Note that the code sample here will not work to log in the user, as I removed extraneous code to focus on the fact that onreadystatechange is never called. When this code is run in qml, the following output is produced. Notice that readystatechange is never invoked.
[code]
import QtQuick 2.0
Rectangle
{
Component.
{
formPost("http://
formPost("https:/
formPost("https:/
}
function formPost(location)
{
var req = new XMLHttpRequest();
{
if (req.readyState == 4)
{
}
}
}
}
[/code]
[output]
Starting /usr/lib/
Posting to http://
Posting to https:/
Posting to https:/
Ready state changed to 2 for https:/
Ready state changed to 3 for https:/
Ready state changed to 3 for https:/
Ready state changed to 3 for https:/
Ready state changed to 4 for https:/
Data received for https:/
Ready state changed to 2 for http://
Ready state changed to 3 for http://
Ready state changed to 3 for http://
Ready state changed to 3 for http://
Ready state changed to 3 for http://
Ready state changed to 4 for http://
Data received for http://
[/output]
However, essentially the identical code in a browser does show that the https endpoint for npr does work. Note that when I include the proper credenitals, the code works in the browser, but in qml onreadystatechange is never called.
[code]
<HTML>
<HEAD>
<SCRIPT>
function init()
{
formPost("http://
formPost("https:/
formPost("https:/
}
function formPost(location)
{
var req = new XMLHttpRequest();
{
if (req.readyState == 4)
{
}
}
}
</SCRIPT>
</HEAD>
<BODY onload=init()>
<P>Form post test</P>
</BODY>
</HTML>
[/code]
[output]
Posting to http://
Posting to https:/
Posting to https:/
XMLHttpRequest cannot load http://
Ready state changed to 4 for http://
Data received for http://
XMLHttpRequest cannot load https:/
Ready state changed to 4 for https:/
Data received for https:/
POST https:/
Ready state changed to 2 for https:/
Ready state changed to 3 for https:/
Ready state changed to 4 for https:/
Data received for https:/
[/output]
description: | updated |
Changed in ubuntu-ui-toolkit: | |
status: | New → Confirmed |
Changed in ubuntu-ui-toolkit (Ubuntu): | |
importance: | Undecided → Medium |
status: | New → Confirmed |
no longer affects: | ubuntu-ui-toolkit |
may be an old issue in qml? /msg00595. html and http:// www.qtcentre. org/threads/ 44629-Using- XMLHttpRequest- for-HTTPS- Post-to- server- with-SSL- certificate
see https://<email address hidden>