fffy2366 / android-query

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

Patch, Delete, Put Http methods , planned ? is there easy way to implement ? #84

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This are methods needed for restful clients, is it possible to easy implement 
it ?  Very nice library , Thank you. 

Original issue reported on code.google.com by dohan.rene@gmail.com on 10 Sep 2012 at 8:56

GoogleCodeExporter commented 8 years ago
Sorry , I see now Put and Delete , I dont see Patch but I dont need it now and 
I see how those are implemented.. Thank you

Original comment by dohan.rene@gmail.com on 10 Sep 2012 at 9:27

GoogleCodeExporter commented 8 years ago
Since I have no experience and no API that I can test "Patch" call, it probably 
won't be supported unless there's more demand for this feature.

Delete and put is already supported.

Original comment by tinyeeliu@gmail.com on 30 Nov 2012 at 2:08

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I added this class 
(http://stackoverflow.com/questions/12207373/http-patch-request-from-android?ans
wertab=active#tab-top) to com.androidquery.callback package.

Later I modified the class AbstrackAQuery.java (in package com.androidquery) 
and I added the next methods:

    public <K> T patch(String url, String contentHeader, HttpEntity entity, Class<K> type, AjaxCallback<K> callback){

        callback.url(url).type(type).method(AQuery.METHOD_PATCH).header("Content-Type", contentHeader).param(AQuery.POST_ENTITY, entity);       
        return ajax(callback);

    }

    public <K> T patch(String url, JSONObject jo, Class<K> type, AjaxCallback<K> callback){

        try{

            StringEntity entity = new StringEntity(jo.toString(), "UTF-8");
            return patch(url, "application/json", entity, type, callback);
        }catch(UnsupportedEncodingException e){
            throw new IllegalArgumentException(e);
        }

    }

And the last steep, I added to Constants.java (package com.androidquery.util):
public static final int METHOD_PATCH = 5;

These changes worked for me.
I hope this can help you.

You can find the android-query.jar and source here 
https://bitbucket.org/cpalosrejano/android-query/downloads

Original comment by cpalosre...@gmail.com on 12 Feb 2014 at 10:37