Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19042] Windows: HTTPClient GET on an incorrect URL throws onload instead of onerror

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2015-06-24T13:57:22.000+0000
Affected Version/sRelease 4.1.0
Fix Version/sRelease 4.1.0
ComponentsWindows
Labelsqe-4.1.0
ReporterEwan Harris
AssigneeChristopher Williams
Created2015-06-18T20:38:19.000+0000
Updated2015-06-30T18:09:31.000+0000

Description

Description

When doing a HTTP GET on an incorrect URL the HTTPClient will throw onLoad rather than onError.
var win = Ti.UI.createWindow({backgroundColor: 'white'});

var lbl = Ti.UI.createLabel({
    text: 'Tap me!',
    color: 'black'
})

var url = 'http://httpbin.org/gert';

lbl.addEventListener('click', function(){

    var client = Ti.Network.createHTTPClient({
        onload : function(e) {
            alert('onload');
        },
        onerror : function(e) {
            alert('onerror');
        }
    });
    client.open('GET', url);
    client.send();
});


win.add(lbl);
win.open();

Steps To Reproduce

1. Add the above code to an app.js 2. Build to a device or emulator 3. Tap the label

Actual Result

An alert will be shown with onload

Expected Result

An alert should be shown with onerror

Comments

  1. Christopher Williams 2015-06-23

    [~eharris] What is the typical behavior on other platforms? Does it fire onerror for any 400+ or 500+ status codes, and onload for 200/300+ codes?
  2. Lokesh Choudhary 2015-06-30

    Verified the fix. We get onerror now . Closing. Environment: Appc Studio: 4.1.0.201506261427 Ti SDK: 4.1.0.v20150630084319 Ti CLI: 4.0.1 Alloy: 1.6.2 Windows: 8.1 Enterprise 64-bit APPC NPM: 4.1.0-1 APPC CLI: 4.1.0-4 Device: Nokia Lumia 928 - Windows Phone 8.1 Windows emulator : 8.1

JSON Source