Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25291] Windows: Calling send with data will upgrade from a GET to a POST

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2017-11-08T17:28:13.000+0000
Affected Version/sRelease 6.1.2, Release 6.2.0
Fix Version/sRelease 7.0.0
ComponentsWindows
Labelsparity
ReporterEwan Harris
AssigneeEwan Harris
Created2017-09-15T14:16:12.000+0000
Updated2017-11-17T01:31:25.000+0000

Description

Description

When performing a GET request and providing the optional data param the SDK will upgrade the request from GET to POST, this isn't in line with other platforms and causes problems for modules like ti.cloud which always send an empty data object
var win = Ti.UI.createWindow({
    title: 'stuff',
    backgroundColor: '#fff'
});

var label = Ti.UI.createLabel({
    text: 'click me',
    color: "#333",
    font: {
        fontSize: 20
    }
});

label.addEventListener('click', function() {
    var url = 'https://httpbin.org/anything';
    var client = Ti.Network.createHTTPClient({
        onload : function(e) {
            alert("method was: " + JSON.parse(this.responseText).method);
            Ti.API.info(this.responseText);
        },
        onerror : function(e) {
            Ti.API.debug(e.error);
            alert('error');
        },
        timeout : 5000
    });
    client.open("GET", url);
    client.send({foo:'bar'});
})

win.add(label);
win.open()

Steps to reproduce

Add the above code to an existing app.js and build for Windows

Tap the label

Actual

Request is changed to a POST

Expected

Request should stay as get

Comments

  1. Ewan Harris 2017-09-18

    Master: https://github.com/appcelerator/titanium_mobile_windows/pull/1112
  2. Abir Mukherjee 2017-11-17

    Tested on SDK 7.0.0.v20171116132144 installed from CLI. Fix is verified.

JSON Source