Merge branch 'features/login' into develop

This commit is contained in:
GME 2018-11-25 17:45:09 +01:00
commit 91889cb162

View file

@ -64,8 +64,7 @@ public class HttpCallHandler {
BufferedReader bufferedReader = null; BufferedReader bufferedReader = null;
HttpURLConnection urlConnection = null; HttpURLConnection urlConnection = null;
try{ try{
System.out.println("executePostHttp"); System.out.println("CALL EXECUTE POST HTTP");
URL url = new URL(urlParam); URL url = new URL(urlParam);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST"); connection.setRequestMethod("POST");
@ -74,23 +73,40 @@ public class HttpCallHandler {
connection.setDoOutput(true); connection.setDoOutput(true);
connection.setDoInput(true); connection.setDoInput(true);
System.out.println("coucou");
JSONObject jsonParam = new JSONObject(); JSONObject jsonParam = new JSONObject();
jsonParam.put("email",params[0]); jsonParam.put("email",params[0]);
jsonParam.put("password",params[1]); jsonParam.put("password",params[1]);
System.out.println("jsonParam : "+jsonParam.toString());
DataOutputStream os = new DataOutputStream(connection.getOutputStream()); DataOutputStream os = new DataOutputStream(connection.getOutputStream());
os.writeBytes(jsonParam.toString()); os.writeBytes(jsonParam.toString());
int statusCode = connection.getResponseCode();
if(statusCode != 200){
System.out.println("Error response");
System.out.println(statusCode);
}
inputStream = urlConnection.getInputStream();
if(inputStream == null){
System.out.println("Error inputStream");
}
bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
StringBuilder stringBuilder = new StringBuilder();
String line;
while ((line = bufferedReader.readLine())!=null){
stringBuilder.append(line);
}
System.out.println("String builder response : "+stringBuilder.toString());
JSONObject json = new JSONObject(stringBuilder.toString());
System.out.println("JSON : "+json);
os.flush(); os.flush();
os.close(); os.close();
System.out.println("STATUS "+String.valueOf(connection.getResponseCode()));
System.out.println("MSG "+connection.getResponseMessage());
connection.disconnect(); connection.disconnect();
return null; return null;