[TIMOB-115] HTTPClient doesn't seem to work with some URLs
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:52:02.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 0.7.0 |
Components | iOS |
Labels | n/a |
Reporter | Nolan Wright |
Assignee | Blain Hamon |
Created | 2011-04-15T02:23:50.000+0000 |
Updated | 2011-04-17T01:52:02.000+0000 |
Description
Here's a test case. the responseText comes back empty.
<html>
<head>
</head>
<body>
<div style='-webkit-border-radius:8px;
background-color:#FFFFCC;
border:#878787 solid 1px;
font-size:12pt;
overflow:hidden;
padding:0;
position:relative;
display:block;
height:auto;
width:auto;
margin:3px 9px 17px;
list-style:none'>
<p id='salmodia'>Carregando ...</p>
</div>
<script>
var xhr = Titanium.Network.createHTTPClient();
// set on ready state change function
xhr.onreadystatechange = function()
{
if (this.readyState == 4)
{
Titanium.UI.createAlertDialog({message:this.responseText}).show();
document.getElementById('salmodia').innerHTML = this.responseText;
}
};
// open the client
xhr.open('GET','http://www.liturgiadashoras.org/Horas/1terca_laudes.htm');
// send the data
xhr.send(null);
</script>
</body>
</html>
It turns out the page in question was in a Windows 1252 charset. The fix has been made and pushed so that the charset is detected (not many charsets yet) and returned unmodified by responsetext. For inserting in html, this is okay. However, calling titanium methods with a non-UTF8 charset does run the risk of the API treating it as Mac Roman.