JSONFunction 修正
完全に現実トウヒ。
今って Get メソド対応のみ、なんですが RESTful なソレに対応できるように直しておきたいなと。以下なカンジの定義になってますが
public static JSONObject getJSONfromURL(String url, DefaultHttpClient httpclient) throws IOException, ClientProtocolException, RuntimeException, JSONException { InputStream is = null; HttpGet httpget = new HttpGet(url); is = httpclient.execute(httpget, new ResponseHandler<InputStream>() { @Override public InputStream handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
以下なメソドを追加して
public static JSONObject RequestExecute(HttpRequestBase method, DefaultHttpClient httpclient) throws IOException, ClientProtocolException, RuntimeException, JSONException { InputStream is = httpclient.execute(method, new ResponseHandler<InputStream>() { @Override public InputStream handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
何とかできんかな、と。
とりあえず考えないといけないのが
- DELETE メソドの場合、通常はレスポンスヘッダのみ返却
- つうことは DELETE 用、というかヘッダのみ返却なメソドを用意すれば良いのか
- 適切なメソドの名前を付けて云々
というあたりで良いのかな。
とりあえず API を作らねば。