package network;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Net;
import com.badlogic.gdx.net.HttpRequestBuilder;
import com.badlogic.gdx.utils.JsonValue;

/**
 * Created by root on 12.03.15.
 */
public class NetworkHelper {
    private static String host = "localhost";
    private static int port = 5000;

    public static void sendPostRequest(String route, String data, Net.HttpResponseListener listener){
        HttpRequestBuilder requestBuilder = new HttpRequestBuilder();
        String url = host + ":" + port + "/api" + route;
        Net.HttpRequest httpRequest = requestBuilder.newRequest().method(Net.HttpMethods.POST).url(url).build();
        httpRequest.setHeader("Content-Type", "application/json");
        httpRequest.setContent(data);

        Gdx.net.sendHttpRequest(httpRequest, listener);
    }

    public static void sendGetRequest(String route, Net.HttpResponseListener listener){
        HttpRequestBuilder requestBuilder = new HttpRequestBuilder();
        String url = host + ":" + port + "/api" + route;
        Net.HttpRequest httpRequest = requestBuilder.newRequest().method(Net.HttpMethods.GET).url(url).build();
        httpRequest.setHeader("Content-Type", "application/json");

        Gdx.net.sendHttpRequest(httpRequest, listener);

    }
}

@@ -755,24 +755,74 @@
 ent(data);%0A%0A
+        NetworkHelper.printRequest(httpRequest);%0A%0A
         Gdx.
@@ -1329,11 +1329,347 @@
 ;%0A%0A    %7D
+%0A%0A    private static void printRequest(Net.HttpRequest httpRequest)%7B%0A        System.out.println(%22URL: %22 + httpRequest.getUrl());%0A        System.out.println(%22Method: %22 + httpRequest.getMethod());%0A        System.out.println(%22Headers: %22 + httpRequest.getHeaders());%0A        System.out.println(%22Content: %22 + httpRequest.getContent());%0A    %7D
 %0A%7D%0A

Print method for httpRequests in NetworkHelper