Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15158] iOS: createHttpClient cannot determine the charset encoding from HTML meta tag. gives status code 500

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2017-07-27T21:10:34.000+0000
Affected Version/sRelease 3.1.3
Fix Version/sn/a
ComponentsiOS
Labelsqe-3.1.3
ReporterPriya Agarwal
AssigneeEric Merriman
Created2013-09-13T11:19:29.000+0000
Updated2017-07-27T21:10:34.000+0000

Description

This is not a regression.
var win1 = Ti.UI.createWindow({
    backgroundColor: 'white',
});
var text = Ti.UI.createLabel({
    text: '',
});
win1.add(text);
win1.open();
charsetTest("http://kangaechu.com/utf8.html");
charsetTest("http://kangaechu.com/shiftjis.html");
charsetTest("http://kangaechu.com/eucjp.html");
charsetTest("http://kangaechu.com/iso2022jp.html");
 
function charsetTest(url){
    var xhr = Ti.Network.createHTTPClient();
     
    xhr.onload = function() {
        if(this.status == 200) {
            var html = this.responseText;
            if(html == null){
                text.text = text.text + url + ' is null.\n\n';
            }
            else if(html.match(/<body>([\s\S]*)<\/body>/)){
                var body = RegExp.$1;
                text.text = text.text + url + body;
            }else{
                text.text = text.text + url + ' is 200, but no body element.\n\n';
            }
        }else{
            text.text = text.text + url + ' status code is ' + this.status + '\n\n';
        }
    };
    xhr.onerror = function() {
        text.text = text.text + url + ' status code is ' + this.status + '\n\n';
 
    };
    xhr.open("GET", url, false);
    xhr.send();
     
}
Steps to Reproduce: 1)Copy paste the code in app.js and run the app. Expected Result: 1)The application should not crash. Following output should be shown on screen: http://kangaechu.com/utf8.html Hello! This encoding is "UTF-8". こんにちわ http://kangaechu.com/shiftjis.html Hello! This Encoding is "Shift_JIS". こんにちわ http://kangaechu.com/eucjp.html Hello! This encoding is "EUC-JP". こんにちわ http://kangaechu.com/iso2022jp.html Hello! This encoding is "ISO-2022-JP". $B$3$s$K$A$o(B Actual Result: 1)http://kangaechu.com/utf8.html status code is 500 http://kangaechu.com/shiftjis.html status code is 500 http://kangaechu.com/eucjp.html status code is 500 http://kangaechu.com/iso2022jp.html status code is 500

Comments

  1. Priya Agarwal 2013-12-02

    Issue still occurs on Tested Environment: Appcelerator Studio: 3.2.0.201311272052 SDK:3.2.0.v20131127194046 alloy: 1.3.0-beta acs: 1.0.9 npm: 1.3.2 titanium: 3.2.0-beta titanium-code-processor: 1.1.0-beta Xcode:5.0.2 OS: Mac OSX 10.9 Device: iphone5(V7.0.4) But now getting error as: Result: http://kangaechu.com/utf8.html status code is 404 http://kangaechu.com/shiftjis.html status code is 404 http://kangaechu.com/eucjp.html status code is 404
  2. Lee Morris 2017-07-27

    Closing due to inactivity. If this issue still exists, please raise a new ticket.

JSON Source