yangkong / android-query

Automatically exported from code.google.com/p/android-query
0 stars 0 forks source link

Support PUT DELETE #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Personally i'm interested in library support for PUT/DELETE requests
and https.

Original issue reported on code.google.com by peter....@aigens.com on 21 Jun 2012 at 8:20

GoogleCodeExporter commented 9 years ago
Add HTTP DELETE support.

Original comment by tinyeeliu@gmail.com on 21 Aug 2012 at 2:50

GoogleCodeExporter commented 9 years ago
very interested in PUT support

Original comment by irapha...@gmail.com on 24 Aug 2012 at 1:54

GoogleCodeExporter commented 9 years ago
Can you provide some use cases of put?

I would like to support PUT but there are couple options.

1. Take an HttpEntity
2. Take a String of content type and byte[]
3. Take various object types and set the proper content type header

Original comment by peter....@aigens.com on 24 Aug 2012 at 5:12

GoogleCodeExporter commented 9 years ago
Hi Peter. Many thanks for DELETE support.

In the first view for PUT method we can use the same scheme as for POST and 
allow developers check for server messages (like 501 error etc.).

For content type headers and objects we can use available methods as well as 
for POST. For example developer can apply necessary content-type header for 
request and POST/PUT object like:
AjaxCallback<JSONObject> cb = new AjaxCallback<JSONObject>();
cb.header("Content-Type", "application/json");

StringEntity se = new StringEntity(postJson.toString()); // If we want to send 
json object for example
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
        "application/json"));

Map<String, Object> params = new HashMap<String, Object>();
params.put(AQuery.POST_ENTITY, se);
cb.params(params);

I hope this help :).

Original comment by yaroslav...@gmail.com on 24 Aug 2012 at 6:17

GoogleCodeExporter commented 9 years ago
Put is now supported in latest beta. Keep in mind this method is not widely 
tested as there's not much popular services that support put. Please share your 
input on how to make put easy for your use case.

Example:

StringEntity entity = new StringEntity(new JSONObject().toString());
aq.put(url, "application/json", entity, JSONObject.class, cb);

Original comment by tinyeeliu@gmail.com on 29 Aug 2012 at 6:40

GoogleCodeExporter commented 9 years ago
Many thanks, PUT works fine.

Original comment by yaroslav...@gmail.com on 5 Sep 2012 at 6:12

GoogleCodeExporter commented 9 years ago
Mark fixed for now until user request more PUT usage patterns.

Original comment by tinyeeliu@gmail.com on 6 Sep 2012 at 9:42

GoogleCodeExporter commented 9 years ago
Hi Peter.

I work on a new project and client web-service require http DELETE with request 
body like POST or PUT requests. As I see android-query supports DELETE requests 
without body only. Can you add support for DELETE requests with body?

P.S. I investigated this issue and found a good solution for this, see 
http://stackoverflow.com/questions/3773338/httpdelete-with-body/3820549#3820549

Original comment by yaroslav...@gmail.com on 5 Oct 2012 at 7:24

GoogleCodeExporter commented 9 years ago
So that API only usable from Android?

Just curious how other platform like web (javascript) and on iOS would
do that easily.
It does seem out of the norm and http client's HttpDelete doesn't even
let you set the entity body.

You sure that's the only way to call that API?

If so probably need to implement that workaround but I doubt it's
going to be useful to general public.

Original comment by tinyeeliu@gmail.com on 5 Oct 2012 at 8:10

GoogleCodeExporter commented 9 years ago
As I understand DELETE request shouldn't use body but can, because this doesn't 
clearly forbidden in the protocol description.

HttpDelete extends HttpRequestBase but HttpPost extends 
HttpEntityEnclosingRequestBase which has setEntity method. Proposed solution 
only extends HttpDelete from HttpEntityEnclosingRequestBase instead of 
HttpRequestBase. So we can use setEntity for request body.

Some web services require body for this request so I think this functionality 
will be usefull for many people.

Original comment by yaroslav...@gmail.com on 5 Oct 2012 at 12:33

GoogleCodeExporter commented 9 years ago

Original comment by tinyeeliu@gmail.com on 5 Oct 2012 at 1:58

GoogleCodeExporter commented 9 years ago
Reopened this to check if body with delete can be supported.

Original comment by tinyeeliu@gmail.com on 5 Oct 2012 at 1:59

GoogleCodeExporter commented 9 years ago
Hi Peter! Any news about support delete request with body?

Original comment by yaroslav...@gmail.com on 23 Oct 2012 at 10:43

GoogleCodeExporter commented 9 years ago
Due to lack of way to test DELETE with body, I will close this unless there's 
further demand.

If you can point out a popular public API that accept DELETE with batch, I will 
reopen it. 

Original comment by tinyeeliu@gmail.com on 14 Dec 2012 at 10:16

GoogleCodeExporter commented 9 years ago
PUT is used by couchdb so you know how important it is... it enables a keyed 
document to be created vs. the db deciding on a location for it.

Original comment by humanli...@gmail.com on 28 Feb 2013 at 11:56

GoogleCodeExporter commented 9 years ago
PUT and DELETE is already supported.

Original comment by peter....@aigens.com on 28 Feb 2013 at 11:59

GoogleCodeExporter commented 9 years ago
Yes I am using both and works great.

Original comment by humanli...@gmail.com on 28 Feb 2013 at 9:34