Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14954] iOS: ASI HTTP Library converts DELETE requests to POST requests

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-03-03T23:50:36.000+0000
Affected Version/sRelease 3.1.3
Fix Version/s2014 Sprint 05, 2014 Sprint 05 API, Release 3.2.3, Release 3.3.0
ComponentsiOS
Labelsn/a
ReporterRick Blalock
AssigneeVishal Duggal
Created2013-08-23T14:59:03.000+0000
Updated2014-03-24T21:54:21.000+0000

Description

The ASIHTTP lib converts DELETE requests to POST. Reference the file here: https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/ASI/ASIHTTPRequest.m#L561 Per a typical RESTful service, DELETE is a normal verb used for...deleting a resource. This needs to be supported.

Comments

  1. Tim Poulsen 2013-08-23

    The HTTP client object should support ALL verbs, in particular those in RFC 2616 (http://ietf.org/rfc/rfc2616). See http://annevankesteren.nl/2007/10/http-methods for an even more comprehensive list.
  2. Rick Blalock 2013-08-26

    Why would it be invalid?
  3. Rick Blalock 2013-12-09

    I agree with Tim that all REST verbs should be supported and not converted.
  4. Jamil Spain 2013-12-09

    I need to demo a rest api adapter for Cisco this week demonstrating we can do at a minimum GET, POST, PUT, DELETE.. Let me know if this can be pushed in with 3.2.0 SDK
  5. Bert Grantges 2013-12-09

    we are also doing some work for demoing an interface layer that leverages HTTP verbs - as a core demo for our platform. Anything we can do to push this into 3.2 would be huge.
  6. Vishal Duggal 2014-03-03

    master - https://github.com/appcelerator/titanium_mobile/pull/5411
  7. Pedro Enrique 2014-03-03

    Backport for 3.2.X https://github.com/appcelerator/titanium_mobile/pull/5412
  8. Vishal Duggal 2014-03-03

    Note to QE. Do not close ticket till backport PR is merged for 3.2.3 release.
  9. Wilson Luu 2014-03-24

    Closing ticket as fixed. Verified two cases: 1. The failure case (this ticket), which is using SDK 3.2.2.GA, was able to *successfully* send a DELETE request to a POST url 2. The fix, which is using SDK 3.2.3 and 3.3.0, was able to send a DELETE request to a POST url and receive a *405 error code* from the server (expected) Using the default Titanium Classic app, I used this code to verify the fix:
       label1.addEventListener('click', function(e){
       	// accepts only POST requests
       	var url = 'http://httpbin.org/post';
       	
       	var client = Ti.Network.createHTTPClient({
       		
       		onload : function(e) {
       			var msg = 'onload: ' + this.responseText;
       			Ti.API.info(msg);
       			alert(msg);
       		},
       		
       		onerror : function(e) {
       			// var msg = 'onerror: ' + 'error code -> ' + e.code + ', error -> ' + e.error;
       			var msg = 'onerror: ' + this.statusText;
       			Ti.API.error(msg);
       			alert(msg);
       		},
       		
       		cache: false
       	});
       	
       	client.open('DELETE', url);
       	client.send('DELETE THE MONKEY');
       });
       
    *Tested on:* Appcelerator Studio, build: 3.2.3.201403190645 SDK build: 3.2.3.v20140324094107, 3.3.0.v20140324131123 CLI: 3.2.1 Xcode: 5.1 Devices: iphone 5 (7.0.6), iphone 5s (7.1)

JSON Source