Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15065] Android: HTTPClient does not send body for DELETE requests

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2014-02-05T23:02:03.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterDavide Cassenti
AssigneeIngo Muschenetz
Created2013-09-06T12:50:22.000+0000
Updated2017-11-21T07:55:39.000+0000

Description

Problem description

When using the HTTP verb 'DELETE', the body does not seem to be sent out, when passing it to the send() method.

Steps to reproduce

var payload = {
	"first": {
		"id" : "11"
	},
	"second" : "TEST"
};

var xhr = Titanium.Network.createHTTPClient({
	onload: function (e) {
		alert(this.responseText);
	}
});
xhr.open('DELETE', 'SOMESERVER');
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(JSON.stringify(payload));
Running the code, on the server side there is no data received; using PHP, I both verified $_POST and json_decode(file_get_contents('php://input')) and they are empty. Changing the method to POST or PUT will show the data on the server.

Comments

  1. Tim Poulsen 2013-11-06

  2. Andrew Skinner 2014-01-21

    I'm curious if there's an update for this issue? It's a tiny change to the code. It's easy to make the change in the code for iOS and re-build but the Android source code is not exposed so we are a bit stuck here.
  3. Ingo Muschenetz 2014-02-05

    This apparently is not native behavior on Android, and is generally not supported by other platforms (iOS appears to be an exception). As iOS is the outlier, we won't/can't bring all the platforms into line. I would suggest passing needed data along the URL.
  4. Andrew Skinner 2014-02-05

    Ingo, there is code in both the Android and iOS Titanium SDKs to explicitly change DELETE requests to POST requests if you try to pass a request body with a DELETE. Titanium should not be making this decision, it should be left up to the user whether they want to make a DELETE request with a body. It doesn't seem like it relates to what the native behavior is, since Titanium is getting involved before it ever reaches the OS.
  5. Ingo Muschenetz 2014-02-05

    We are addressing the iOS issue. Do you have a link for the Android location you are referencing?
  6. Andrew Skinner 2014-02-05

    Line 1107 of the HTTPClient implementation. A variable is set called isPostOrPut and later on line 1130 it will only send a request body if the method is a POST or PUT request. DELETE requests fall through. https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java
  7. Ingo Muschenetz 2014-02-06

    As noted, it appears that it would be relatively trivial to change the logic around: https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java#L1130 However, if we did so, would it work? http://stackoverflow.com/questions/10338615/sending-http-delete-request-in-android Suggests that it might not even send the data.
  8. Andrew Skinner 2014-02-06

    Yeah, digging further in there seems to be some debate as to whether DELETEs should be able to have a body, even though the RFC seems to indicate they can. I guess it would need to be tested. I know that when I made the modification to the iOS code, it started sending the request body without issue. I have not tested with Android as I'm not as familiar with recompiling the SDK.
  9. Lee Morris 2017-03-30

    Closing ticket as "Won't Fix". There has been no update for a while. If there is any problem, please open a new ticket.
  10. Marian Kucharcik 2017-11-21

    Hi guys, this is not fixed in 6.3.0, http request doesn't send body for DELETE type. Can you please make it work as iOS does(iOS doesn't have a problem). Thanks

JSON Source