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);

        NetworkHelper.printRequest(httpRequest);

        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);

    }

    private static void printRequest(Net.HttpRequest httpRequest){
        System.out.println("URL: " + httpRequest.getUrl());
        System.out.println("Method: " + httpRequest.getMethod());
        System.out.println("Headers: " + httpRequest.getHeaders());
        System.out.println("Content: " + httpRequest.getContent());
    }
}

@@ -145,23 +145,23 @@
 gdx.
-utils.JsonValue
+net.NetJavaImpl
 ;%0A%0A/
@@ -262,16 +262,23 @@
 host = %22
+http://
 localhos
@@ -816,36 +816,77 @@
 uest);%0A%0A        
-Gdx.
+NetJavaImpl net = new NetJavaImpl();%0A        
 net.sendHttpRequ
@@ -1327,12 +1327,88 @@
     
-Gdx.
+printRequest(httpRequest);%0A        NetJavaImpl net = new NetJavaImpl();%0A        
 net.

Add http before localhost. Changed library executing requests. https://code.google.com/p/libgdx/issues/detail?id=1280