Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18971] iOS: HTTPClient - If you make a DELETE REST call, then HTTPClient's onload method is not called

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2016-07-12T07:47:13.000+0000
Affected Version/sRelease 4.0.1
Fix Version/sn/a
ComponentsiOS
Labelshttpclient, qe-4.0.1
ReporterWilson Luu
AssigneeHans Knöchel
Created2015-06-01T21:09:18.000+0000
Updated2016-07-12T07:47:20.000+0000

Description

*Details:* If you make a valid DELETE REST call, then HTTPClient's onload method is not called. *Notes:* * This issue is not reproducible on Android * Even though the onload method is not being called, the DELETE request still goes through * Other Http REST calls (e.g. POST) are triggering HTTPClient's onload method *Steps to reproduce:*

Create a Titanium *and* Arrow project from Appc Studio

In the Titanium project, replace the app.js with the attached app.js

Next, select the Arrow project and run *Local Arrow Server*

In the console, copy the port number after http://127.0.0.1:

In the Titanium project's app.js, replace URL_PREFIX (line 2) with your machine's ip address and Arrow project's port number e.g. http://172.16.3.129:62756

In the same app.js file, replace API_KEY (line 8) with your Arrow project's apikey_development; /conf/default.js

Next, install your Titanium project to an iOS device; make sure the device is on the same wifi network as your machine

Open the app and press 1. Create; wait for *CREATED MONKEY LORD* alert

Next, press 2. DELETE

*Actual:* The onload method is never called i.e. *DATA DELETED* alert is never triggered in the onload method. *Expected:* The onload method should be called if a valid DELETE Http REST called is made.

Attachments

FileDateSize
app.js2015-06-01T20:53:32.000+00001896

Comments

  1. Ingo Muschenetz 2015-06-02

    Not currently scheduling this for a release, but let me know if you feel otherwise.
  2. Hans Knöchel 2016-07-12

    Closing issue for now. I tested the requests using an open REST testing-service:
       // specify the arrow api endpoint
       var URL_PATH = 'http://jsonplaceholder.typicode.com';
       
       function makeRequest(path, verb, onLoad, data) {
            var xhr = Ti.Network.createHTTPClient({
               onload: onLoad,
               onerror: function() {
                   Ti.API.error('Error ' + verb + ': ' + this.status + '; ' + this.responseText);
               }
           });
           
           xhr.open(verb, URL_PATH + path);   
           
           if(data) {
               xhr.setRequestHeader("Content-Type","application/json");
               xhr.send(JSON.stringify(data));      
           }
           else {
               xhr.send();
           }
       }
       
       var win = Ti.UI.createWindow({
           backgroundColor: 'white',
           layout: 'vertical'
       });
       
       var postButton = Ti.UI.createButton({
           title: '1. Create',
           top: '30%'
       });
       win.add(postButton);
       postButton.addEventListener('click', function(e) {
           
           Ti.API.info('####: POST a monkey');
           
           var data = {
               first_name: 'MONKEY',
               last_name: 'LORD',
               email: 'monkey@lord.com'  
           };
           makeRequest('/posts', 'POST', function(_e) {
       		Ti.API.warn(this.status);
               if(this.status === 201) {
                   alert('CREATED MONKEY LORD');
               }
           }, data);
       });
       
       var deleteButton = Ti.UI.createButton({
           title: '2. DELETE',
           top: '20dp'
       });
       win.add(deleteButton);
       deleteButton.addEventListener('click', function(e) {
           makeRequest('/posts/1', 'DELETE', function(_e) {
               
               Ti.API.info('####: DELETE calling onload');
       		Ti.API.warn(this.status);
               
               if(this.status === 200) {
                   alert('DATA DELETED');
               }
           });
       });
       
       win.open();
       
    The onLoad is triggered and the response is 200 (not 204, because there is response). Please validate to make sure you see the same. I would suspect that something was wrong on the arrow-side.

JSON Source