오윤석

GET, DELETE method의 경우 querystring 추가

......@@ -17,6 +17,8 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Iterator;
import java.util.Set;
public class Api {
public interface Callback {
......@@ -32,8 +34,18 @@ public class Api {
public void run() {
ApiResult apiResult;
try {
Log.d("test", "callApi");
URL url = new URL("http://" + Api.DOMAIN + endpoint);
String queryString = "";
if(("GET".equals(method) || "DELETE".equals(method)) && params != null) {
Set<String> keys = params.keySet();
Iterator<String> iter = keys.iterator();
while(iter.hasNext()) {
String key = iter.next();
queryString += "&" + key + "=" + params.get(key).getAsString();
}
queryString = "?" + queryString.substring(1);
}
URL url = new URL("http://" + Api.DOMAIN + endpoint + queryString);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(method);
......